How can the issue of duplicated "http://" in URLs be avoided in PHP code?
Issue: Duplicated "http://" in URLs can be avoided by checking if the URL already contains "http://" before appending it to the URL string.
// Check if the URL already contains "http://" before appending it
$url = "http://example.com";
if (strpos($url, "http://") === false) {
$url = "http://" . $url;
}
echo $url;