3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ new Widget(tags: ['a', 'b', 'c']), new Widget(tags: ['c', 'd', 'e']), new Widget(tags: ['x', 'y', 'a']), ]; class Widget { public function __construct( public array $tags = [], ) {} } class Benchmark { private $startTime; private $endTime; public function start() { $this->startTime = hrtime(true); } public function end() { $this->endTime = hrtime(true); } public function getElapsedTime() { return ($this->endTime - $this->startTime)/1_000_000_000; } } // Example usage $benchmark = new Benchmark(); $trimClosure = trim(...); $strtolowerClosure = strtolower(...); // ==================================== $benchmark->start(); // Code to benchmark for ($i = 0; $i < 1000000; $i++) { $title = ' PHP 8.5 Released '; $slug1 = $title |> $trimClosure |> $strtolowerClosure; // string(15) "php-85-released" } $benchmark->end(); echo "Elapsed time: " . $benchmark->getElapsedTime() . " seconds\n"; $benchmark->start(); // Code to benchmark for ($i = 0; $i < 1000000; $i++) { $title = ' PHP 8.5 Released '; $slug2 = $strtolowerClosure( $trimClosure($title) ); // string(15) "php-85-released" } $benchmark->end(); echo "Elapsed time: " . $benchmark->getElapsedTime() . " seconds\n"; var_dump($slug1 === $slug2);
Output for 8.5.0
Elapsed time: 0.154070909 seconds Elapsed time: 0.104444702 seconds bool(true)
Output for 8.3.5 - 8.3.37, 8.4.1 - 8.4.15
Parse error: syntax error, unexpected token ">" in /in/uu0Q5 on line 46
Process exited with code 255.

preferences:
15.59 ms | 1167 KiB | 5 Q