php - validate URL by FILTER_VALIDATE_URL -



php - validate URL by FILTER_VALIDATE_URL -

i validating url filter_validate_url function.

$url_1 = "http://example.com"; $url_2 = "http://http://example.com"; if (filter_var($url_1, filter_validate_url)) { echo "url valid"; } else { echo "url invalid"; }

it's giving me valid url message in $url_1 , $url_2. shouldn't that. sec url not valid. what's right way solve issue? thanks.

as per docs on validation filters, filter_validate_url validate url rfc 2396 standards.

there's been give-and-take on examples still pass filter_validate_url filter.

this means can utilize filter some validation, can't depend on solely if need 100% valid url conditions still satisfy rfc, plus valid url still homecoming 404.

your best approach test valid url test url after validating as per answer

php validation

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -