$url = "https://www.example.com"; if (filter_var($url, FILTER_VALIDATE_URL)) { echo "Valid URL"; } else { echo "Invalid URL"; }
$url = "example.com"; if (filter_var($url, FILTER_VALIDATE_URL)) { echo "Valid URL"; } else { echo "Invalid URL"; }Output: Invalid URL Library/package: The isUrl function is a part of the PHP filter extension which provides a set of filters for validating and sanitizing various types of data. This function is available in PHP version 5.2.0 and above. There is no need to install any external package or library to use this function.