3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * Format URL * * @param $url * @return string */ function format_url($url) { $parsed_url = parse_url($url); $host = get_domain($parsed_url['host'], false); $path = preg_replace('#index\.[a-z]+#', '', $parsed_url['path']); $url = $host . $path; if (isset($parsed_url['query'])) { $url .= '?' . $parsed_url['query']; } return rtrim($url, '/'); } /** * Compare two formatted urls * * @param string $url_1 * @param string $url_2 * @return bool */ function compare_urls($url_1, $url_2) { return format_url($url_1) === format_url($url_2); } $url_1 = 'http://seos.bolseo.ru/index.php?module=2&siteID=235'; $url_2 = 'seos.bolseo.ru/?module=2&siteID=235'; var_dump(compare_urls($url_1, $url_2));
Output for 7.0.0 - 7.1.10
Fatal error: Uncaught Error: Call to undefined function get_domain() in /in/fK6SH:12 Stack trace: #0 /in/fK6SH(32): format_url('http://seos.bol...') #1 /in/fK6SH(38): compare_urls('http://seos.bol...', 'seos.bolseo.ru/...') #2 {main} thrown in /in/fK6SH on line 12
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Call to undefined function get_domain() in /in/fK6SH on line 12
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: get_domain() in /in/fK6SH on line 12
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: get_domain() in /in/fK6SH on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: get_domain() in /in/fK6SH on line 12