Posted by Janwillem Borleffs on 09/30/78 11:29
Domestos wrote:
> Hi can you please help me with the code for the following...
>
> I need to pattern match a valid Hyper-Link string from a user input...
>
> i.e.
>
> http://www.domain.com
>
> or
>
> www.domain.com
>
> etc...
>
Sure you could use a regular expression, but perhaps it's more convenient to
try to fetch the content instead:
$url = strpos($url, 'http://') === 0 ? $url : "http://$url";
if (@file_get_contents($url)) {
// URL is valid
}
JW
Navigation:
[Reply to this message]
|