3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function isUrl($value) { $alpha = "a-z\x80-\xFF"; $domain = "[0-9$alpha](?:[-0-9$alpha]{0,61}[0-9$alpha])?"; $topDomain = "[$alpha](?:[-0-9$alpha]{0,17}[$alpha])?"; return (bool) preg_match("(^https?://(?:(?:$domain\\.)*$topDomain|\\d{1,3}\.\\d{1,3}\.\\d{1,3}\.\\d{1,3}|\[[0-9a-f:]{3,39}\])(:\\d{1,5})?(/\\S*)?\\z)i", $value); } var_dump(isUrl("https://test.cz")); var_dump(isUrl("http://test.cz")); var_dump(isUrl("https://www.test.cz")); var_dump(isUrl("http://www.test.cz")); var_dump(isUrl("http://cz"));
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
bool(true) bool(true) bool(true) bool(true) bool(true)
Output for hhvm-3.10.0

Process exited with code 153.