3v4l.org

run code in 300+ PHP versions simultaneously
<?php // String manipulation (explode and manual comparison) $sstart = microtime(true); for ($i = 0; $i < 100000; $i++) { $uri = 'user/123'; $segments = explode('/', $uri); if ($segments[0] === 'user' && is_numeric($segments[1])) { $id = $segments[1]; } } $string = (microtime(true) - $sstart); echo 'String manipulation: ' . $string . ' seconds'.PHP_EOL; // Regex equivalent $rstart = microtime(true); for ($i = 0; $i < 100000; $i++) { $uri = 'user/123'; if (preg_match('#^user/(\d+)$#', $uri, $matches)) { $id = $matches[1]; } } $regex = (microtime(true) - $rstart); echo 'Regex: ' . $regex . ' seconds'.PHP_EOL; echo 'Diff: '.((($regex - $string) / $string) * 100).'%';
Output for git.master_jit
String manipulation: 0.009099006652832 seconds Regex: 0.0086829662322998 seconds Diff: -4.5723718687769%
Output for git.master
String manipulation: 0.022066116333008 seconds Regex: 0.02192497253418 seconds Diff: -0.63964041835941%
Output for rfc.property-hooks
String manipulation: 0.0090570449829102 seconds Regex: 0.0087389945983887 seconds Diff: -3.5116352532379%

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:
28.08 ms | 408 KiB | 5 Q