3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urls = [ 'www.example.com/myurl.html?unwantedthngs#hastag', 'www.example.com/myurl.html' ]; foreach ($urls as $url) { var_export(['strtok: ', strtok($url, '?')]); echo "\n"; var_export(['strstr/true: ', strstr($url, '?', true)]); // not reliable echo "\n"; var_export(['explode/2: ', explode('?', $url, 2)[0]]); // limit alls func to stop searching after first encounter echo "\n"; var_export(['substr/strrpos: ', substr($url, 0, strrpos( $url, "?"))]); // not reliable; still not with strpos() echo "\n---\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 'strtok: ', 1 => 'www.example.com/myurl.html', ) array ( 0 => 'strstr/true: ', 1 => 'www.example.com/myurl.html', ) array ( 0 => 'explode/2: ', 1 => 'www.example.com/myurl.html', ) array ( 0 => 'substr/strrpos: ', 1 => 'www.example.com/myurl.html', ) --- array ( 0 => 'strtok: ', 1 => 'www.example.com/myurl.html', ) array ( 0 => 'strstr/true: ', 1 => false, ) array ( 0 => 'explode/2: ', 1 => 'www.example.com/myurl.html', ) array ( 0 => 'substr/strrpos: ', 1 => '', ) ---

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