3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $string = '//google.com/fgdgfg/rt'; if (filter_var($string, FILTER_VALIDATE_URL)) { return $string; } $string = trim($string); $string = str_replace(' ', '', $string); $string = iconv('utf-8', 'us-ascii//TRANSLIT', $string); if (!preg_match('/^https?:\/\//', $string)) { $string = 'http://' . $string; } if (!filter_var($string, FILTER_VALIDATE_URL)) { throw new Exception('Ссылка'); } echo $string;