How to Validate a Website URL in PHP

How can I use PHP to check if the URL is a valid link or just a normal text.

You can use PHP native function – filter_var to check if the string is normal test or a valid URL. Here is the example
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
    die('Its a invalid URL');
}
3 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments