Jump to content

Tutorial example produced unexpected results


plough

Recommended Posts

https://www.w3schools.com/php/phptryit.asp?filename=tryphp_filter_adv3 is a tutorial example.  It attempts to validate what appears to be a valid URL but claims it is not.

I see this forum gets little use, so has the language changed since the example was created, is there a mistake in the example, or is the problem on my end in the browser?

I am using the latest FireFox browser under Windows 10.

Link to comment
Share on other sites

There's nothing odd with this one. You're missing the fact that the program checks for two things

  • Valid URL (FILTER_VALIDATE_URL)
  • Has a query string (FILTER_FLAG_QUERY_REQUIRED)

"https://www.w3schools.com" is a valid URL, but lacks a query string and therefore does not succeed the check.

Edited by Funce
PHP Flags
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...