How can PHP be used to validate user input for URLs, specifically checking for the presence of "http://"?
When validating user input for URLs in PHP, you can check for the presence of "http://" by using the strpos() function to search for the substring within the input string. If the substring is found at the beginning of the input string, the URL is considered valid. Here is a sample PHP code snippet that demonstrates this validation process:
$userInput = $_POST['url'];
if (strpos($userInput, 'http://') === 0) {
echo "URL is valid";
} else {
echo "Invalid URL format";
}