3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Human { public function speak() { return "I can speak"; } public function walk() { return "I can walk"; } public function jump() { return "I can jump"; } } /* calling parent is working but lots of duplication */ /* class Man extends Human { // can speak and walk but overrides some of the human function public function walk() { return parent::walk() . " fast"; } public function speak() { return parent::speak() . " fast"; } } */ class Man { // can speak and walk but overrides some of the human function public function __construct(Human $human) { $this->_human = $human; $this->_override = ["walk", "speak"]; } private function _method($parentResult) { return static::class . ": ". $parentResult . " fast"; } public function __call($name, $arguments) { return in_array($name, $this->_override) ? $this->_method($this->_human->$name()) : $this->_human->$name(); // here we could check if method exists } } // woman is an example for static access to instance methods of parent --> could be also static at parent (just easier to test with the code here) class Woman { private static function _method($parentResult) { return static::class . ": ". $parentResult . " fast"; } public static function __callStatic($name, $arguments) { $_override = ["walk", "speak"]; $_human = new Human(); return in_array($name, $_override) ? self::_method($_human->$name()) : $_human->$name(); // here we could check if method exists } } $human = new Human(); echo $human->speak() . "\r\n"; echo $human->walk(); echo "\r\n"; $man = new Man(new Human()); echo $man->speak() . "\r\n"; echo $man->walk() . "\r\n"; echo $man->jump(); echo "\r\n"; $woman = new Woman(); echo $woman::speak() . "\r\n"; echo $woman::walk() . "\r\n"; echo $woman::jump();

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.3.60.0120.00618.56
8.3.50.0150.00616.36
8.3.40.0040.01118.84
8.3.30.0110.00418.70
8.3.20.0000.00721.73
8.3.10.0000.00723.46
8.3.00.0000.00718.16
8.2.180.0110.00416.63
8.2.170.0040.01122.96
8.2.160.0120.00321.10
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0000.00922.30
8.2.120.0000.00726.35
8.2.110.0110.00721.00
8.2.100.0090.00317.84
8.2.90.0040.00419.17
8.2.80.0030.00617.97
8.2.70.0060.00317.38
8.2.60.0000.00918.05
8.2.50.0040.00418.10
8.2.40.0080.00020.38
8.2.30.0050.00220.32
8.2.20.0030.00618.13
8.2.10.0040.00418.12
8.2.00.0020.00518.09
8.1.280.0150.00325.92
8.1.270.0040.00424.02
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0000.01021.31
8.1.230.0080.00317.77
8.1.220.0040.00417.74
8.1.210.0030.00718.77
8.1.200.0060.00317.48
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0000.00818.59
8.1.160.0000.00718.77
8.1.150.0090.00020.18
8.1.140.0070.00019.54
8.1.130.0040.00420.68
8.1.120.0070.00017.52
8.1.110.0030.00617.43
8.1.100.0020.00517.43
8.1.90.0040.00417.48
8.1.80.0040.00417.44
8.1.70.0040.00417.51
8.1.60.0030.00617.47
8.1.50.0060.00317.48
8.1.40.0070.00017.49
8.1.30.0000.00817.66
8.1.20.0040.00417.52
8.1.10.0000.00717.48
8.1.00.0000.00717.41
8.0.300.0040.00418.77
8.0.290.0070.00016.75
8.0.280.0030.00318.50
8.0.270.0040.00417.20
8.0.260.0030.00316.82
8.0.250.0030.00317.05
8.0.240.0050.00317.03
8.0.230.0070.00017.01
8.0.220.0030.00316.88
8.0.210.0000.00716.88
8.0.200.0030.00317.00
8.0.190.0000.00817.02
8.0.180.0040.00416.91
8.0.170.0030.00316.99
8.0.160.0080.00016.80
8.0.150.0040.00416.87
8.0.140.0000.00716.93
8.0.130.0040.00313.43
8.0.120.0000.00716.82
8.0.110.0000.00716.86
8.0.100.0070.00016.82
8.0.90.0040.00416.98
8.0.80.0070.01316.91
8.0.70.0040.00416.99
8.0.60.0000.00716.88
8.0.50.0040.00417.03
8.0.30.0030.01617.21
8.0.20.0130.00517.41
8.0.10.0040.00416.94
8.0.00.0120.00616.73
7.4.330.0050.00015.55
7.4.320.0050.00216.46
7.4.300.0060.00016.56
7.4.290.0070.00016.50
7.4.280.0030.00616.61
7.4.270.0070.00016.46
7.4.260.0050.00216.45
7.4.250.0080.00016.48
7.4.240.0000.00716.57
7.4.230.0030.00316.44
7.4.220.0060.01616.38
7.4.210.0100.01016.59
7.4.200.0000.00716.39
7.4.160.0080.00816.53
7.4.150.0160.00617.40
7.4.140.0060.01217.86
7.4.130.0060.01916.43
7.4.120.0120.01016.48
7.4.110.0120.00416.58
7.4.100.0060.01216.59
7.4.90.0100.00716.25
7.4.80.0090.00819.39
7.4.70.0100.00616.54
7.4.60.0100.00616.43
7.4.50.0070.00316.45
7.4.40.0110.00716.30
7.4.30.0160.00716.36
7.4.10.0060.00914.89
7.4.00.0130.00414.99
7.3.330.0070.00013.40
7.3.320.0050.00013.15
7.3.310.0000.00816.41
7.3.300.0030.00316.34
7.3.290.0060.00816.34
7.3.280.0090.00816.35
7.3.270.0030.01517.40
7.3.260.0100.00716.44
7.3.250.0150.00616.42
7.3.240.0110.00616.36
7.3.230.0100.00716.51
7.3.210.0070.01016.30
7.3.200.0140.00416.53
7.3.190.0150.00016.55
7.3.180.0130.00316.42
7.3.170.0150.00016.39
7.3.160.0100.00616.52
7.3.130.0100.01014.96
7.3.120.0090.00914.87
7.3.110.0040.01514.93
7.3.100.0130.00314.81
7.3.90.0040.00914.87
7.3.80.0030.00614.88
7.3.70.0080.00314.66
7.3.60.0030.00614.59
7.3.50.0000.01314.87
7.3.40.0030.01214.69
7.3.30.0060.00314.53
7.3.20.0030.00716.50
7.3.10.0070.00716.36
7.3.00.0000.01216.50
7.2.330.0150.00316.84
7.2.320.0060.01116.83
7.2.310.0030.01416.84
7.2.300.0130.00416.90
7.2.290.0120.01216.89
7.2.260.0080.00814.64
7.2.250.0000.01514.87
7.2.240.0090.00615.03
7.2.230.0090.01215.30
7.2.220.0070.00714.97
7.2.210.0040.00415.30
7.2.200.0030.01415.05
7.2.190.0040.01114.91
7.2.180.0060.00315.25
7.2.170.0060.00914.84
7.2.160.0080.00415.08
7.2.150.0100.00616.95
7.2.140.0030.00916.92
7.2.130.0090.00317.02
7.2.120.0000.01017.00
7.2.110.0030.01016.89
7.2.100.0070.01016.88
7.2.90.0030.01017.07
7.2.80.0030.01016.82
7.2.70.0080.00817.01
7.2.60.0490.00616.03
7.2.50.0030.00716.80
7.2.40.0040.01116.96
7.2.30.0070.00416.78
7.2.20.0030.00716.96
7.2.10.0120.00616.94
7.2.00.0020.01218.21
7.1.330.0080.00415.70
7.1.320.0030.01015.75
7.1.310.0070.00715.45
7.1.300.0070.00715.74
7.1.290.0060.00615.58
7.1.280.0030.00715.81
7.1.270.0030.00915.85
7.1.260.0070.00716.04
7.1.250.0040.00715.70
7.1.240.0000.01015.77
7.1.230.0060.00915.95
7.1.220.0110.00315.60
7.1.210.0030.00615.88
7.1.200.0110.00215.74
7.1.190.0070.00715.56
7.1.180.0040.00415.78
7.1.170.0040.01215.94
7.1.160.0040.01115.70
7.1.150.0090.00315.70
7.1.140.0090.00615.82
7.1.130.0080.00015.91
7.1.120.0070.00415.69
7.1.110.0060.00315.71
7.1.100.0300.01015.92
7.1.90.0170.00015.93
7.1.80.0040.01515.68
7.1.70.0030.00616.64
7.1.60.0040.00816.47
7.1.50.0070.01116.41
7.1.40.0030.01116.24
7.1.30.0060.00616.29
7.1.20.0030.01116.37
7.1.10.0060.00716.25
7.1.00.0030.00516.17
7.0.330.0060.00815.41
7.0.320.0150.00015.51
7.0.310.0030.01015.39
7.0.300.0030.00615.40
7.0.290.0030.00915.22
7.0.280.0030.00615.41
7.0.270.0090.00315.36
7.0.260.0040.00415.43
7.0.250.0000.01015.29
7.0.240.0030.01415.53
7.0.230.0040.01215.57
7.0.220.0110.00715.49
7.0.210.0090.00315.52
7.0.200.0090.00316.14
7.0.190.0060.00816.05
7.0.180.0030.01115.96
7.0.170.0050.00715.76
7.0.160.0060.00515.80
7.0.150.0020.01115.85
7.0.140.0030.00715.76
7.0.130.0040.00715.85
7.0.120.0070.00815.91
7.0.110.0070.00815.86
7.0.100.0030.01015.92
7.0.90.0070.00715.82
7.0.80.0040.00715.75
7.0.70.0080.00615.90
7.0.60.0030.00615.95
7.0.50.0050.00715.96
7.0.40.0020.00814.41
7.0.30.0080.00614.62
7.0.20.0060.00814.58
7.0.10.0110.00314.61
7.0.00.0060.00514.38
5.6.400.0040.00813.92
5.6.390.0040.01114.65
5.6.380.0050.00514.37
5.6.370.0030.00714.37
5.6.360.0030.01214.62
5.6.350.0000.00914.41
5.6.340.0000.01414.56
5.6.330.0060.00814.58
5.6.320.0090.00614.38
5.6.310.0100.00714.25
5.6.300.0030.00914.43
5.6.290.0030.00814.40
5.6.280.0000.01114.50
5.6.270.0060.00914.34
5.6.260.0030.01014.12
5.6.250.0040.00414.46
5.6.240.0090.00614.41
5.6.230.0030.01214.34
5.6.220.0000.01314.36
5.6.210.0000.01414.64
5.6.200.0070.00714.54
5.6.190.0070.00714.48
5.6.180.0070.00714.82
5.6.170.0000.01514.30
5.6.160.0100.00314.48
5.6.150.0090.00314.54
5.6.140.0060.00614.16
5.6.130.0040.00714.16
5.6.120.0060.00614.32
5.6.110.0030.00614.24
5.6.100.0060.00614.64
5.6.90.0060.00914.80
5.6.80.0060.00614.47
5.6.70.0060.00614.42
5.6.60.0130.00014.54
5.6.50.0070.00713.98
5.6.40.0120.00014.16
5.6.30.0070.00714.28
5.6.20.0110.00314.41
5.6.10.0120.00414.39
5.6.00.0100.00014.18

preferences:
44.05 ms | 401 KiB | 5 Q