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

by John Email

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;

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)