Code Snippet: Make sure a url starts with http://

if( strpos($url, ‘http://’) === false )
$url = ‘http://’ . $url;

Or if you are a fan of single line functions

$url = ( strpos($url, ‘http://’) === false ) ? ‘http://’ . $url : $url;

Leave a Reply