3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait AssignsPropertiesValues { public function assign(...$props): static { foreach ($props as $propName => $propVal) { $this->$propName = $propVal; } return $this; } } class Person { use AssignsPropertiesValues; public function __construct( public string $firstName, public int $age ) { } } class Person2 { use AssignsPropertiesValues; public string $firstName; public int $age; } class Person3 { use AssignsPropertiesValues; public string $firstName { set => strtoupper($value); } public int $age; } $p1 = new Person('Pig',5)->assign(firstName: 'Peppa', age: 6); $p2 = new Person2()->assign(firstName: 'George', age: 3); $p3 = new Person3()->assign(firstName: 'Danny', age: 7); var_dump($p1, $p2, $p3);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.10.0350.00917.39

preferences:
139.27 ms | 993 KiB | 7 Q