Re: Regular expression - URL validator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wagner Garcia Campagner wrote:
Thanks Jim,

Your sugestion worked perfect for me!!

I have another question:

After i validate this URL i want to put a link with this URL in my page.

The problem is that if the URL is like (www.aol.com), when i create the
link, this URL is appended with the URL of my site. The result is a link
pointing to: http://<mywebsite>/www.aol.com

But if the URL is like (http://aol.com), then the link is created correct.

Is there a way to avoid the first situation... so the link is created
correct?

Thanks again,
Wagner.

You could always do a string comparison for http(s)? in the url

if ( strpos($url, array('https://', 'http://')) === false ) {
	$url = 'http://'.$url;
}

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux