Created
September 1, 2022 15:28
-
-
Save guimadaleno/6e08de6116f4d46926d4c95361af2e97 to your computer and use it in GitHub Desktop.
Is valid URL function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Test if URL is valid | |
* @author SpikeZ | |
* @param string $str | |
* @return bool | |
*/ | |
function is_valid_url ($uri) | |
{ | |
if (preg_match( '/^(http|https):\\/\\/[a-z0-9_]+([\\-\\.]{1}[a-z_0-9]+)*\\.[_a-z]{2,5}'.'((:[0-9]{1,5})?\\/.*)?$/i' ,$uri)) | |
return $uri; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment