3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Invalid example class Animal { public function eat(){} } class Cat extends Animal { public function meow(){ echo "meow"; } } class A { function foo(): Animal { return new Animal(); } } class B extends A { function foo(): Cat { return new Cat(); } } if (rand(0, 1)) { $object = new A; } else { $object = new B; } $animal = $object->foo(); $animal->meow(); // This code fails %50 of the time as not all animals can meow.

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)
7.4.40.0140.00316.43
7.4.30.0060.00916.46
7.4.20.0160.00316.21
7.4.10.0120.00416.17
7.4.00.0040.01216.45
7.3.160.0060.00916.23
7.3.150.0120.00316.15
7.3.140.0000.01516.21
7.3.130.0130.00316.17
7.3.120.0110.00416.20
7.3.110.0030.01216.21
7.3.100.0090.00616.32
7.3.90.0120.00916.38
7.3.80.0090.00916.14
7.3.70.0120.00316.27
7.3.60.0060.00916.07
7.3.50.0080.00816.20
7.3.40.0070.00716.21
7.3.30.0060.00916.27
7.3.20.0100.00716.34
7.3.10.0110.00716.21
7.3.00.0060.01016.23
7.2.290.0110.00616.51
7.2.280.0090.00616.55
7.2.270.0070.01416.05
7.2.260.0060.01016.18
7.2.250.0030.01216.04
7.2.240.0160.00016.38
7.2.230.0060.01516.30
7.2.220.0110.00816.48
7.2.210.0000.01616.12
7.2.200.0060.00916.23
7.2.190.0130.00316.30
7.2.180.0120.00316.22
7.2.170.0040.01616.32
7.2.160.0110.00716.34
7.2.150.0090.00916.59
7.2.140.0140.00316.47
7.2.130.0140.00416.57
7.2.120.0110.00716.52
7.2.110.0090.00816.35
7.2.100.0080.00816.47
7.2.90.0070.01016.46
7.2.80.0100.00716.48
7.2.70.0030.01516.49
7.2.60.0090.00916.46
7.2.50.0110.00516.38
7.2.40.0130.00316.38
7.2.30.0130.00316.38
7.2.20.0070.00816.43
7.2.10.0090.00616.33
7.2.00.0090.01016.30

preferences:
35.78 ms | 400 KiB | 5 Q