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); } error_log("Failed login from ".$_SERVER['REMOTE_ADDR']); 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 1CoXJ
Output for 5.3.0 - 7.1.0
Notice: Undefined index: REMOTE_ADDR in /in/VkLD3 on line 12 Failed login from
Output for 5.1.2 - 5.2.17
Notice: Undefined index: REMOTE_ADDR in /in/VkLD3 on line 12 Failed login from
Output for 4.3.2 - 5.1.1
Notice: Undefined index: REMOTE_ADDR in /in/VkLD3 on line 12 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/VkLD3 on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/VkLD3 on line 4 Warning: assert(): Assertion failed in /in/VkLD3 on line 13 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/VkLD3 on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/VkLD3 on line 4 Warning: assert(): Assertion failed in /in/VkLD3 on line 14 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/VkLD3 on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/VkLD3 on line 4 Warning: assert(): Assertion failed in /in/VkLD3 on line 15 Failed login from
Output for 4.3.0 - 4.3.1
Notice: Undefined index: REMOTE_ADDR in /in/VkLD3 on line 12 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/VkLD3 on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/VkLD3 on line 4 Warning: assert() [http://www.php.net/function.assert]: Assertion failed in /in/VkLD3 on line 13 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/VkLD3 on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/VkLD3 on line 4 Warning: assert() [http://www.php.net/function.assert]: Assertion failed in /in/VkLD3 on line 14 Notice: Use of undefined constant PHP_URL_HOST - assumed 'PHP_URL_HOST' in /in/VkLD3 on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/VkLD3 on line 4 Warning: assert() [http://www.php.net/function.assert]: Assertion failed in /in/VkLD3 on line 15 Failed login from