FILTER_VALIDATE_URL
In the above code we can get the message that Correct, URL Validation passed. Same way you can change the data and get the staus.
Optional FlagsFILTER_FLAG_SCHEME_REQUIRED - additional check of RFC compliant (like http://example)FILTER_FLAG_HOST_REQUIRED - additional check of host name (like http://www.example.com FILTER_FLAG_PATH_REQUIRED - additional check of path to domain name (like www.example.com/php_tutorial/) FILTER_FLAG_QUERY_REQUIRED - With a query string (like "example.php?id=34&cat=student&class=Four") FILTER_FLAG_SCHEME_REQUIRED & FILTER_FLAG_HOST_REQUIRED are deprecated in PHP 7.3 as they are included within FILTER_VALIDATE_URL. Validating URL with pathWe can add one optional flagFILTER_FLAG_PATH_REQUIRED to check if any path is added after the URL. Without presence of a path this validation will fail. This flag checks minimum one forward slash ( / ) after the URL to be present. Here is the code
Here is the list of URL which will pass and which will fail in the validation.
Validating URL with query stringWith the optional flag ofFILTER_FLAG_QUERY_REQUIRED we can validate URL only if a valid query string is present ( along with URL ) . Here is the code to check
Here is a list of URL which will pass and which will fail the URL validation process
Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
![]() |
filter_list:PHP list of filters available and how to display
filter_has_var: checking the existance of variable in PHP filter_var: Validating variable using filter id FILTER_VALIDATE_FLOAT: Validating Float data FILTER_VALIDATE_INT: Validating Integer with Maximum and Minimum range FILTER_VALIDATE_REGEXP: Validating REgular Expression FILTER_VALIDATE_EMAIL: Validating Email FILTER_VALIDATE_URL: Validating URL with query string and path FILTER_VALIDATE_IP: Validating IPV4 and IPV6 address FILTER_VALIDATE_BOOLEAN: Validating boolean variable FILTER_SANITIZE_STRING: Sanitize string FILTER_SANITIZE_URL: Sanitize url |