i'm trying to use filter_var to validate URLs that have been entered by a user, but it seems not to work in all cases. I've requested a fix for this some time ago on PHP.net, but to no avail.
Besides regexes (yes, a few have been posted on stackoverflow), is there a PHP version that does work or any other method?
The problem I'm facing is that the following string get's validated, which should not:
http://http://www.google.com
Test script:
$url = $_REQUEST['url'];
if (filter_var("http://" . $url, FILTER_VALIDATE_URL))
$filter="true";
else
$filter="false";
echo "Filter var result of concat with http is:" . $filter . "<br>";
Expected result:
I expect it to return false when i run the script with http://www.google.com and true when i run it with www.google.com
Actual result:
It returns true in both cases