How to validate is URL in Php?
In this post, This function checks whether a variable is of type URL or not.
1. Code:
<?php function checkIsUrl($var){ return false !== filter_var($var, FILTER_VALIDATE_URL); } var_dump(checkIsUrl("https://soltuts.com/tag/php/")); echo "<br>"; var_dump(checkIsUrl("on")); ?>
2. Example:
Input:
Input: "https://soltuts.com/" Input: "Soltuts"
Output:
Output: true Output: false