Skip to content

Instantly share code, notes, and snippets.

/test
Created Apr 17, 2014

Embed
What would you like to do?
Testing PHP's VALIDATE_URL filter
<?php
$testUrls = array(
'www.asdf.com',
'example.org',
'/peach.kingdom',
'x.something.co.uk',
'http:myname.com',
'https://www.sdf.org'
);
echo '<pre>';
print_r($testUrls);
echo '<br>';
foreach ($testUrls as $url) {
echo 'URL: ' . filter_var($url, FILTER_VALIDATE_URL);
echo '<br>';
}
/* -------------------------
Output will be:
Array
(
[0] => www.asdf.com
[1] => example.org
[2] => /peach.kingdom
[3] => x.something.co.uk
[4] => http:myname.com
[5] => https://www.sdf.org
)
URL:
URL:
URL:
URL:
URL:
URL: https://www.sdf.org
------------------------- */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.