3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urls = [ 'http://evil.com?example.org/foo/bar', 'http://evil.com?example.org/foo/bar?baz#quux', 'http://evil.com?example.org?baz#quux', 'http://evil.com?example.org#quux', ]; foreach ( $urls as $url ) { $bits = parse_url( $url ); if ( isset( $bits['host'] ) && strpos( $bits['host'], '?' ) !== false ) { list( $host, $query ) = explode( '?', $bits['host'], 2 ); $bits['host'] = $host; $bits['query'] = $query . ( isset( $bits['path'] ) ? $bits['path'] : '' ) . ( isset( $bits['query'] ) ? '?' . $bits['query'] : '' ); unset( $bits['path'] ); } var_dump( $bits ); }
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(8) "evil.com" ["query"]=> string(19) "example.org/foo/bar" } array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(8) "evil.com" ["query"]=> string(23) "example.org/foo/bar?baz" ["fragment"]=> string(4) "quux" } array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(8) "evil.com" ["query"]=> string(15) "example.org?baz" ["fragment"]=> string(4) "quux" } array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(8) "evil.com" ["query"]=> string(11) "example.org" ["fragment"]=> string(4) "quux" }

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:
180.13 ms | 407 KiB | 5 Q