3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php print get_domain("http://somedomain.co.uk"); // outputs 'somedomain.co.uk' function get_domain($url) { $pieces = parse_url($url); $domain = isset($pieces['host']) ? $pieces['host'] : ''; if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) { return $regs['domain']; } return false; }
Output for 4.3.3 - 7.1.0
somedomain.co.uk
Output for 4.3.0 - 4.3.2
Notice: Undefined index: domain in /in/8TJU9 on line 9