3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function domainGetFromURL($url, $strip_www = true) { echo print_r(parse_url($url), 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 = 'domain.ru'; echo domainGetFromURL($url, false);
Output for 5.3.0 - 7.1.0
Array ( [path] => domain.ru ) Notice: Undefined index: host in /in/0buOS on line 13
Output for 4.3.0 - 5.2.17
Array ( [path] => domain.ru ) Notice: Undefined index: host in /in/0buOS on line 13