Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP FILTER_VALIDATE_URL Filter

PHP FILTER_VALIDATE_URL Filter


PHP Filter Reference Manual Complete PHP Filter Reference Manual

Example

Check whether the URL format is valid:

The output of the code above is:

https://www.runoob.com 是正确的 URL

Definition and Usage

The FILTER_VALIDATE_URL filter validates a value as a URL.

Possible flags:


Example

The following example removes illegal characters from the $url variable and then checks whether it is a valid URL:

Example

The output of the code is shown below:

https://www.runoob.com 是正确的 URL

The following checks whether the URL contains a valid query string:

Example

The output of the code is shown below:

https://www.runoob.com 是错误的 URL
https://www.runoob.com?s=php 是正确的 URL

PHP Filter Reference Manual Complete PHP Filter Reference Manual