3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $urls = array( 'http://www.website.com/path1/path2/file1.php?query1=true&query2=false', 'http://website.com/path1/path2/file1.php?query1=true&query2=false', 'http://website/path1/path2/file1.php?query1=true&query2=false', 'http://www.website.com/path1/path2/?query1=true&query2=false', 'http://website.com/path1/path2/?query1=true&query2=false', 'http://website/path1/path2/?query1=true&query2=false', 'http://www.website.com/path1/path2/', 'http://website.com/path1/path2/', 'http://website/path1/path2/', 'http://www.website.com?query1=true&query2=false', 'http://website.com?query1=true&query2=false', 'http://website?query1=true&query2=false', 'www.website.com/path1/path2/file1.php?query1=true&query2=false', 'website.com/path1/path2/file1.php?query1=true&query2=false', 'website/path1/path2/file1.php?query1=true&query2=false', 'www.website.com/path1/path2/?query1=true&query2=false', 'website.com/path1/path2/?query1=true&query2=false', 'website/path1/path2/?query1=true&query2=false', 'www.website.com/path1/path2/', 'website.com/path1/path2/', 'website/path1/path2/', 'www.website.com?query1=true&query2=false', 'website.com?query1=true&query2=false', 'website?query1=true&query2=false', 'https://www.website.com:443/path1/path2/file1.php?query1=true&query2=false', 'https://website.com:443/path1/path2/file1.php?query1=true&query2=false', 'https://website:443/path1/path2/file1.php?query1=true&query2=false', 'https://www.website.com:443/path1/path2/?query1=true&query2=false', 'https://website.com:443/path1/path2/?query1=true&query2=false', 'https://website:443/path1/path2/?query1=true&query2=false', 'https://www.website.com:443/path1/path2/', 'https://website.com:443/path1/path2/', 'https://website:443/path1/path2/', 'https://www.website.com:443?query1=true&query2=false', 'https://website.com:443?query1=true&query2=false', 'https://website:443?query1=true&query2=false', 'www.website.com:443/path1/path2/file1.php?query1=true&query2=false', 'website.com:443/path1/path2/file1.php?query1=true&query2=false', 'website:443/path1/path2/file1.php?query1=true&query2=false', 'www.website.com:443/path1/path2/?query1=true&query2=false', 'website.com:443/path1/path2/?query1=true&query2=false', 'website:443/path1/path2/?query1=true&query2=false', 'www.website.com:443/path1/path2/', 'website.com:443/path1/path2/', 'website:443/path1/path2/', 'www.website.com:443?query1=true&query2=false', 'website.com:443?query1=true&query2=false', 'website:443?query1=true&query2=false', ); $flags = array( 'none' => null, 'scheme' => FILTER_FLAG_SCHEME_REQUIRED, 'scheme + host' => FILTER_FLAG_SCHEME_REQUIRED & FILTER_FLAG_HOST_REQUIRED, 'scheme + host + path' => FILTER_FLAG_SCHEME_REQUIRED & FILTER_FLAG_HOST_REQUIRED & FILTER_FLAG_PATH_REQUIRED, 'scheme + host + path + query' => FILTER_FLAG_SCHEME_REQUIRED & FILTER_FLAG_HOST_REQUIRED & FILTER_FLAG_PATH_REQUIRED & FILTER_FLAG_QUERY_REQUIRED, 'host' => FILTER_FLAG_HOST_REQUIRED, 'host + path' => FILTER_FLAG_HOST_REQUIRED & FILTER_FLAG_PATH_REQUIRED, 'host + path + query' => FILTER_FLAG_HOST_REQUIRED & FILTER_FLAG_PATH_REQUIRED & FILTER_FLAG_QUERY_REQUIRED, 'path' => FILTER_FLAG_PATH_REQUIRED, 'path + query' => FILTER_FLAG_PATH_REQUIRED & FILTER_FLAG_QUERY_REQUIRED, 'query' => FILTER_FLAG_QUERY_REQUIRED ); foreach($urls as $url){ foreach($flags as $k => $flag){ echo "$url => $k :\r\n"; var_dump((bool) filter_var($url, FILTER_VALIDATE_URL, $flag)); } echo "\r\n"; }