3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Struct { function __construct() { foreach (func_get_args() as $name) { $this->$name = null; } } function __invoke() { $values = func_get_args(); $obj = clone $this; foreach (array_keys(get_object_vars($this)) as $index => $name) { if (isset($values[$index])) { $obj->$name = $values[$index]; } } return $obj; } } $Coord = new Struct('x', 'y', 'z'); $Coord->z = 0; $c1 = $Coord(12, 45, -34); print_r($c1); $c2 = $Coord(100, -100); print_r($c2); $Person = new Struct('firstname', 'lastname'); $p1 = $Person('William', 'Wallace'); print_r($p1); $p2 = $Person('Peter', 'Griffin'); print_r($p2); // If only: struct person { function __construct($firstname, $lastname) { $this->firstname = $firstname; $this->lastname = $lastname; } } // So we could: $p1 = person('William', 'Wallace'); // Instead of ubiquitous: $p1 = new Person(array('William', 'Wallace')); // or even $p1 = new Person(array('firstname' => 'William', 'lastname' => 'Wallace')); // or $p1 = Person::create(array('William', 'Wallace')); // etc

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)
5.4.320.0050.03712.52
5.4.310.0030.04112.51
5.4.300.0080.03612.52
5.4.290.0030.04112.52
5.4.280.0090.04012.41
5.4.270.0070.04012.41
5.4.260.0020.04112.41
5.4.250.0110.03512.41
5.4.240.0070.04112.41
5.4.230.0070.03912.40
5.4.220.0080.03512.41
5.4.210.0090.03512.41
5.4.200.0100.03612.41
5.4.190.0090.03512.40
5.4.180.0080.03912.40
5.4.170.0060.03912.41
5.4.160.0060.03712.41
5.4.150.0050.03912.40
5.4.140.0070.03712.09
5.4.130.0080.03512.07
5.4.120.0080.03512.04
5.4.110.0070.03512.04
5.4.100.0100.04012.03
5.4.90.0100.04112.04
5.4.80.0090.03712.04
5.4.70.0050.04012.03
5.4.60.0070.04212.03
5.4.50.0040.03912.03
5.4.40.0070.03412.02
5.4.30.0100.03212.02
5.4.20.0060.04012.01
5.4.10.0070.03412.02
5.4.00.0050.04011.51
5.3.290.0070.04212.80
5.3.280.0090.03612.71
5.3.270.0070.03912.72
5.3.260.0060.03912.71
5.3.250.0060.03812.72
5.3.240.0060.03812.72
5.3.230.0060.03812.71
5.3.220.0130.03712.68
5.3.210.0070.03812.68
5.3.200.0080.03512.68
5.3.190.0060.03812.68
5.3.180.0070.03812.67
5.3.170.0080.03612.67
5.3.160.0070.03812.67
5.3.150.0050.03912.67
5.3.140.0060.03912.66
5.3.130.0080.03812.66
5.3.120.0050.04012.66
5.3.110.0080.03712.66
5.3.100.0070.03612.13
5.3.90.0050.03812.11
5.3.80.0110.03612.10
5.3.70.0070.04112.10
5.3.60.0080.03412.09
5.3.50.0080.03912.04
5.3.40.0050.03812.04
5.3.30.0080.03711.99
5.3.20.0070.03411.77
5.3.10.0100.03011.74
5.3.00.0060.04011.73
5.2.170.0080.0289.23
5.2.160.0030.0319.23
5.2.150.0070.0399.23
5.2.140.0040.0319.22
5.2.130.0050.0289.18
5.2.120.0060.0329.18
5.2.110.0050.0309.19
5.2.100.0060.0299.19
5.2.90.0110.0439.19
5.2.80.0080.0279.18
5.2.70.0050.0319.19
5.2.60.0080.0279.14
5.2.50.0050.0339.11
5.2.40.0030.0319.09
5.2.30.0020.0349.06
5.2.20.0060.0289.05
5.2.10.0070.0258.96
5.2.00.0080.0308.82
5.1.60.0040.0308.11
5.1.50.0050.0298.10
5.1.40.0060.0308.08
5.1.30.0080.0308.43
5.1.20.0030.0318.45
5.1.10.0050.0288.18
5.1.00.0040.0278.18
5.0.50.0040.0276.66
5.0.40.0040.0216.53
5.0.30.0040.0316.34
5.0.20.0040.0196.30
5.0.10.0060.0186.28
5.0.00.0040.0306.27
4.4.90.0010.0184.78
4.4.80.0020.0164.75
4.4.70.0050.0134.76
4.4.60.0030.0174.76
4.4.50.0040.0154.77
4.4.40.0030.0264.71
4.4.30.0010.0194.76
4.4.20.0010.0244.85
4.4.10.0060.0144.85
4.4.00.0010.0284.76
4.3.110.0070.0154.66
4.3.100.0000.0224.67
4.3.90.0050.0134.63
4.3.80.0060.0284.58
4.3.70.0050.0134.63
4.3.60.0040.0134.63
4.3.50.0040.0154.63
4.3.40.0010.0254.54
4.3.30.0010.0173.30
4.3.20.0020.0173.28
4.3.10.0020.0183.24
4.3.00.0030.01711.67

preferences:
138.94 ms | 1394 KiB | 7 Q