3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function cleanUrl($value) { $url = parse_url($value); // Crap URLs (ie. without a scheme) only contain a path. if (!isset($url['host'])) { $url['host'] = rtrim($url['path'], '/'); $url['path'] = null; } $output = ''; $output .= !empty($url['scheme']) ? $url['scheme'] . '://' : 'http://'; // If unspecified, use HTTP. $output .= strtolower($url['host']); $output .= $url['path']; $output .= !empty($url['query']) ? '?' . $url['query'] : null; $output .= !empty($url['fragment']) ? '#' . $url['fragment'] : null; return $output; } cleanUrl('http://google.com');
based on 6XhR6
Output for 5.3.0 - 7.1.0
Notice: Undefined index: path in /in/ieG4k on line 16
Output for 4.3.0 - 5.2.17
Notice: Undefined index: path in /in/ieG4k on line 16