3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function get_domain($url){ $host = parse_url( $url, PHP_URL_HOST ); $host_parts = explode(".", $host); if(count($host_parts)>2){ array_shift($host_parts); } return implode(".", $host_parts); } assert( get_domain("http://najdi.si/") == "najdi.si" ); assert( get_domain("http://www.najdi.si/") == "najdi.si" ); assert( get_domain("http://www.najdi.si.com/") == "najdi.si.com" );
based on 13Fkn
Output for 5.1.2 - 7.1.0
Output for 4.3.2 - 5.1.1
Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/4bL0E on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/4bL0E on line 4 Warning: assert(): Assertion failed in /in/4bL0E on line 13 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/4bL0E on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/4bL0E on line 4 Warning: assert(): Assertion failed in /in/4bL0E on line 14 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/4bL0E on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/4bL0E on line 4 Warning: assert(): Assertion failed in /in/4bL0E on line 15
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/4bL0E on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/4bL0E on line 4 Warning: assert() [http://www.php.net/function.assert]: Assertion failed in /in/4bL0E on line 13 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/4bL0E on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/4bL0E on line 4 Warning: assert() [http://www.php.net/function.assert]: Assertion failed in /in/4bL0E on line 14 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/4bL0E on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/4bL0E on line 4 Warning: assert() [http://www.php.net/function.assert]: Assertion failed in /in/4bL0E on line 15