3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wp_parse_url( $url, $component = -1 ) { $to_unset = array(); $url = strval( $url ); if ( '//' === substr( $url, 0, 2 ) ) { $to_unset[] = 'scheme'; $url = 'placeholder:' . $url; } elseif ( '/' === substr( $url, 0, 1 ) ) { $to_unset[] = 'scheme'; $to_unset[] = 'host'; $url = 'placeholder://placeholder' . $url; } $parts = @parse_url( $url ); if ( false === $parts ) { // Parsing failure. return $parts; } // Remove the placeholder values. foreach ( $to_unset as $key ) { unset( $parts[ $key ] ); } return _get_component_from_parsed_url_array( $parts, $component ); } function _get_component_from_parsed_url_array( $url_parts, $component = -1 ) { if ( -1 === $component ) { return $url_parts; } $key = _wp_translate_php_url_constant_to_key( $component ); if ( false !== $key && is_array( $url_parts ) && isset( $url_parts[ $key ] ) ) { return $url_parts[ $key ]; } else { return null; } } $url = 'http://domain.com'; var_dump( parse_url( $url, PHP_URL_PATH ) ); var_dump( wp_parse_url( $url, PHP_URL_PATH ) );
Output for git.master, git.master_jit, rfc.property-hooks
NULL Fatal error: Uncaught Error: Call to undefined function _wp_translate_php_url_constant_to_key() in /in/ovOYt:36 Stack trace: #0 /in/ovOYt(28): _get_component_from_parsed_url_array(Array, 5) #1 /in/ovOYt(47): wp_parse_url('http://domain.c...', 5) #2 {main} thrown in /in/ovOYt on line 36
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
30.21 ms | 406 KiB | 5 Q