3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input = 'http://#chr├╝tli24/7schwur.ch'; $input = 'www.meinem├╝llerdomain.ch/index/checkMe?param#whatevs'; $input = 'www.jeng.cc'; $pattern = array(); $pattern[] = '/\xE2\x80\x8B/'; $pattern[] = '/ /'; $pattern[] = '@^[a-z]+://@i'; $pattern[] = '/&#8203;/'; $pattern[] = '/\?/'; $pattern[] = '@^www\.@i'; // if entered, remove whitespaces, prepending protocoll and www. $cleaned = preg_replace($pattern, null, idn_to_utf8(mb_strtolower($input, 'UTF-8'))); //echo $cleaned; // if entered, remove trailing dot $cleaned = (substr($cleaned, -1) == '.') ? substr($cleaned, 0, -1) : $cleaned; //echo $cleaned; if (strpos($cleaned, '@') !== false) { echo 'false'; } $val = filter_var(idn_to_ascii($cleaned), FILTER_VALIDATE_URL); var_dump($val); $correct = filter_var('http://'.$cleaned, FILTER_VALIDATE_URL); var_dump($correct); //var_dump(parse_url($correct)); $testdomain = idn_to_ascii($cleaned); var_dump(filter_var($testdomain, FILTER_VALIDATE_URL));
based on Sdoi1
Output for 7.2.0 - 7.2.6, 7.3.0rc3
Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in /in/LPcLW on line 16 Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in /in/LPcLW on line 27 bool(false) string(14) "http://jeng.cc" Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in /in/LPcLW on line 35 bool(false)
Output for 7.3.0alpha1 - 7.3.0beta1
Fatal error: Uncaught Error: Call to undefined function idn_to_utf8() in /in/LPcLW:16 Stack trace: #0 {main} thrown in /in/LPcLW on line 16
Process exited with code 255.
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.1.20
bool(false) string(14) "http://jeng.cc" bool(false)