3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function domainGetFromURL($url, $strip_www = true) { if (!$p = @parse_url($url)) { return ''; } if (strlen($p['host']) == 0) { return ''; } if ($strip_www) { $domain = preg_replace('#^www\.(www\.)*#', '', strtolower($p['host'])); } else { $domain = strtolower($p['host']); } return $domain; } $url = 'http://281654'; echo domainGetFromURL($url, false);
Output for 4.3.0 - 7.2.0
281654