Skip to content

Instantly share code, notes, and snippets.

@dryks
Created February 13, 2018 21:32
Show Gist options
  • Save dryks/9a9807f00348d2986d3749cd6a527b2a to your computer and use it in GitHub Desktop.
Save dryks/9a9807f00348d2986d3749cd6a527b2a to your computer and use it in GitHub Desktop.
Проверка ссылки на абсолютность или относительность preg_match
<?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