Created
February 13, 2018 21:32
-
-
Save dryks/9a9807f00348d2986d3749cd6a527b2a to your computer and use it in GitHub Desktop.
Проверка ссылки на абсолютность или относительность preg_match
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 | |
$testUrl = 'http://www.domain.ru/dir/dir?u=test'; | |
if( preg_match('/^(http|https|ftp):\/\/([A-Z0-9])[A-Z0-9_-]*(\.?[A-Z0-9]+)+?/iU', $testUrl ) ) echo 'yes'; else echo 'no'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment