3v4l.org

run code in 300+ PHP versions simultaneously
<?php function format_url($url) { if(parse_url($url, PHP_URL_SCHEME) === null) { $url = 'http://' . $url; //parse_url() requires scheme to parse URL correctly } $parsed_url = parse_url($url); $formatted_url = get_domain($parsed_url['host'], false); if (isset($parsed_url['path'])) { $formatted_url .= $parsed_url['path']; } if (isset($parsed_url['query'])) { $formatted_url .= '?' . $parsed_url['query']; } $formatted_url = rtrim($formatted_url, '/'); return $formatted_url; } $url = 'http://www.igrushka-spb.ru/index.php?categoryID=1718'; var_dump(format_url($url));
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to undefined function get_domain() in /in/JV7RU:10 Stack trace: #0 /in/JV7RU(27): format_url('http://www.igru...') #1 {main} thrown in /in/JV7RU on line 10
Process exited with code 255.
Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function get_domain() in /in/JV7RU on line 10
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
Notice: Use of undefined constant PHP_URL_SCHEME - assumed 'PHP_URL_SCHEME' in /in/JV7RU on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/JV7RU on line 4 Fatal error: Call to undefined function get_domain() in /in/JV7RU on line 10
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Use of undefined constant PHP_URL_SCHEME - assumed 'PHP_URL_SCHEME' in /in/JV7RU on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/JV7RU on line 4 Fatal error: Call to undefined function: get_domain() in /in/JV7RU on line 10
Process exited with code 255.
Output for 4.3.4 - 4.3.11, 4.4.0 - 4.4.4
Notice: Use of undefined constant PHP_URL_SCHEME - assumed 'PHP_URL_SCHEME' in /in/JV7RU on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/JV7RU on line 4 Fatal error: Call to undefined function: get_domain() in /in/JV7RU on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.3
Notice: Use of undefined constant PHP_URL_SCHEME - assumed 'PHP_URL_SCHEME' in /in/JV7RU on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/JV7RU on line 4 Warning: parse_url(http://http://www.igrushka-spb.ru/index.php?categoryID=1718): Unable to parse url in /in/JV7RU on line 8 Fatal error: Call to undefined function: get_domain() in /in/JV7RU on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant PHP_URL_SCHEME - assumed 'PHP_URL_SCHEME' in /in/JV7RU on line 4 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/JV7RU on line 4 Warning: parse_url(http://http://www.igrushka-spb.ru/index.php?categoryID=1718) [http://www.php.net/function.parse-url]: Unable to parse url in /in/JV7RU on line 8 Fatal error: Call to undefined function: get_domain() in /in/JV7RU on line 10

preferences:
299.22 ms | 402 KiB | 460 Q