I want to validate a URI (not URL only) in PHP, though couldn't find any way to do this.
PHP does have parse_url() but it is not for URIs, it would be helpful to find a proper way to validate URI structures such as the following:
content://com.example.provider/articles/?optional=queries
To validate URIs, you can use the FILTER_VALIDATE_URL filter with the filter_var() function in PHP.
$uri = "content://com.example.provider/articles/?optional=queries"
if (filter_var($uri, FILTER_VALIDATE_URL)) {
// Valid URI, do something here.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With