Filter Validate Url
# PHP FILTER_VALIDATE_URL Filter
* * Complete PHP Filter Reference](#)
## Example
Determine if the URL format is correct:
The output of the above code is:
is a valid URL
* * *
## Definition and Usage
The FILTER_VALIDATE_URL filter validates a value as a URL.
* Name: "validate_url"
* ID-number: 273
Possible flags:
* FILTER_FLAG_SCHEME_REQUIRED - Requires the URL to be RFC-compatible (e.g.,
* FILTER_FLAG_HOST_REQUIRED - Requires the URL to contain a hostname (e.g.,
* FILTER_FLAG_PATH_REQUIRED - Requires the URL to have a path after the domain name (e.g., www..com/example1/test2/)
* FILTER_FLAG_QUERY_REQUIRED - Requires the URL to have a query string (e.g., "example.php?name=Peter&age=37")
* * *
## Example
The following example removes illegal characters from the variable $url, then checks if it is a valid URL:
## Example
The output of the code is as follows:
is a valid URL
The following checks if the URL contains a valid query string:
## Example
The output of the code is as follows:
is not a valid URL is a valid URL
* * Complete PHP Filter Reference](#)
YouTip