3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Challenge 2: Implement AnswerInterface and get Question to echo "4". */ class Question { public function __construct(AnswerInterface $answer) { echo "What is 2 + 2?\n"; $answer = $answer->get()->the()->answer(); if ($answer instanceof AnswerInterface) { echo $answer . PHP_EOL; } } } interface AnswerInterface { public function get(); public function the(); public function answer(); } // start editing here class Answer { public function get() { return $this; } public function the() { return $this; } public function answer() { return 4; } } // end editing here $answer = new Answer; $question = new Question($answer);

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.0150.00418.68
8.3.50.0110.00921.14
8.3.40.0090.00618.77
8.3.30.0100.00320.40
8.3.20.0000.00720.29
8.3.10.0080.00021.92
8.3.00.0080.00022.57
8.2.180.0090.00617.13
8.2.170.0100.00622.96
8.2.160.0030.01022.02
8.2.150.0090.00624.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00019.64
8.2.110.0030.00721.06
8.2.100.0060.00619.64
8.2.90.0030.00619.07
8.2.80.0080.00017.97
8.2.70.0070.00417.50
8.2.60.0000.00917.91
8.2.50.0030.00618.07
8.2.40.0070.00018.10
8.2.30.0040.00418.07
8.2.20.0000.00717.57
8.2.10.0050.00217.78
8.2.00.0040.00717.80
8.1.280.0140.00725.92
8.1.270.0040.00424.66
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0060.00320.72
8.1.230.0070.00322.31
8.1.220.0040.00417.74
8.1.210.0000.00918.77
8.1.200.0030.00617.22
8.1.190.0030.00617.00
8.1.180.0050.00318.10
8.1.170.0040.00418.50
8.1.160.0050.00318.88
8.1.150.0080.00018.59
8.1.140.0040.00417.39
8.1.130.0040.00417.85
8.1.120.0000.00717.41
8.1.110.0040.00417.30
8.1.100.0000.00717.30
8.1.90.0000.00717.42
8.1.80.0040.00417.42
8.1.70.0060.00017.39
8.1.60.0030.00617.50
8.1.50.0040.00417.52
8.1.40.0080.00017.52
8.1.30.0030.00617.64
8.1.20.0000.00817.62
8.1.10.0050.00217.51
8.1.00.0040.00417.38
8.0.300.0060.00318.77
8.0.290.0030.00616.75
8.0.280.0070.00018.53
8.0.270.0000.00717.17
8.0.260.0080.00016.91
8.0.250.0000.00617.00
8.0.240.0000.00716.99
8.0.230.0000.00816.86
8.0.220.0070.00016.93
8.0.210.0000.00716.93
8.0.200.0030.00317.04
8.0.190.0030.00716.98
8.0.180.0000.00716.95
8.0.170.0030.00516.95
8.0.160.0040.00416.88
8.0.150.0040.00416.96
8.0.140.0040.00416.94
8.0.130.0000.00613.34
8.0.120.0060.00316.88
8.0.110.0000.00716.80
8.0.100.0070.00016.97
8.0.90.0000.00716.87
8.0.80.0060.00916.88
8.0.70.0000.00816.96
8.0.60.0040.00416.74
8.0.50.0070.00016.95
8.0.30.0090.01016.84
8.0.20.0120.00617.40
8.0.10.0080.00017.07
8.0.00.0080.01016.83
7.4.330.0030.00315.00
7.4.320.0030.00316.38
7.4.300.0030.00316.59
7.4.290.0040.00416.60
7.4.280.0070.00016.52
7.4.270.0020.00516.61
7.4.260.0030.00616.65
7.4.250.0030.00416.59
7.4.240.0020.00516.49
7.4.230.0020.00516.61
7.4.220.0090.00616.74
7.4.210.0070.01016.60
7.4.200.0000.00716.72
7.4.190.0040.00316.47
7.4.160.0050.01116.60
7.4.150.0040.01517.40
7.4.140.0110.00617.86
7.4.130.0100.00716.52
7.4.120.0090.00816.51
7.4.110.0060.01316.55
7.4.100.0130.00716.52
7.4.90.0060.01216.56
7.4.80.0100.01019.39
7.4.70.0160.00016.68
7.4.60.0160.00016.43
7.4.50.0040.00016.34
7.4.40.0060.01022.77
7.4.30.0100.00716.32
7.4.00.0090.00814.83
7.3.330.0000.00513.32
7.3.320.0020.00213.35
7.3.310.0000.00716.27
7.3.300.0000.00716.33
7.3.290.0120.00616.39
7.3.280.0100.00816.34
7.3.270.0150.00617.40
7.3.260.0120.00616.52
7.3.250.0160.00516.51
7.3.240.0090.00916.32
7.3.230.0030.01316.39
7.3.210.0120.00416.28
7.3.200.0090.00819.39
7.3.190.0030.01416.51
7.3.180.0120.00216.39
7.3.170.0060.00916.40
7.3.160.0100.00616.23
7.3.120.0090.00715.03
7.3.110.0040.01214.76
7.3.100.0030.00714.98
7.3.90.0150.00015.07
7.3.80.0060.01115.10
7.3.70.0030.01214.92
7.3.60.0120.00414.82
7.3.50.0060.00314.55
7.3.40.0060.00614.84
7.3.30.0070.00714.52
7.3.20.0120.00316.71
7.3.10.0070.00916.54
7.3.00.0060.00716.46
7.2.330.0090.00916.37
7.2.320.0070.01516.37
7.2.310.0100.00616.39
7.2.300.0040.01316.44
7.2.290.0130.00316.32
7.2.250.0030.01614.95
7.2.240.0060.01314.89
7.2.230.0060.00915.12
7.2.220.0000.01214.89
7.2.210.0060.00914.55
7.2.200.0070.01015.09
7.2.190.0040.00815.02
7.2.180.0100.00714.95
7.2.170.0100.00315.08
7.2.130.0110.00016.86
7.2.120.0030.00616.84
7.2.110.0100.00316.55
7.2.100.0030.01216.58
7.2.90.0090.00316.80
7.2.80.0100.00316.78
7.2.70.0090.00316.63
7.2.60.0040.01016.82
7.2.50.0090.00316.75
7.2.40.0070.00716.99
7.2.30.0030.01316.80
7.2.20.0120.00016.87
7.2.10.0030.00916.71
7.2.00.0050.00518.11
7.1.330.0030.01215.67
7.1.320.0100.00715.91
7.1.310.0120.00615.74
7.1.300.0070.00715.65
7.1.290.0030.00915.65
7.1.280.0030.01215.43
7.1.270.0000.01415.54
7.1.260.0030.00715.86
7.1.250.0000.00815.54
7.1.200.0080.00415.69
7.1.100.0040.00718.08
7.1.70.0000.00717.19
7.1.60.0090.01519.43
7.1.50.0110.01516.66
7.1.00.0070.03022.43
7.0.200.0040.00416.74
7.0.140.0170.06322.08
7.0.100.0270.06320.18
7.0.90.0070.07719.95
7.0.80.0030.08319.94
7.0.70.0100.08019.87
7.0.60.0070.08719.87
7.0.50.0070.08720.36
7.0.40.0030.08319.96
7.0.30.0230.06720.04
7.0.20.0130.07719.96
7.0.10.0100.08020.03
7.0.00.0170.07320.13
5.6.280.0100.07020.90
5.6.250.0230.06320.65
5.6.240.0170.07020.52
5.6.230.0070.07320.76
5.6.220.0000.09020.62
5.6.210.0100.07320.63
5.6.200.0070.08321.02
5.6.190.0130.07721.07
5.6.180.0070.07321.07
5.6.170.0100.07720.97
5.6.160.0100.08021.05
5.6.150.0000.06321.04
5.6.140.0030.08721.03
5.6.130.0200.07321.01
5.6.120.0000.08721.11
5.6.110.0130.08321.02
5.6.100.0200.07321.14
5.6.90.0100.06720.95
5.6.80.0100.07020.34
5.6.70.0030.08020.43
5.6.60.0070.06320.50
5.6.50.0100.07020.41
5.6.40.0070.06720.34
5.6.30.0130.06320.39
5.6.20.0070.08020.43
5.6.10.0100.07720.40
5.6.00.0070.08020.40
5.5.380.0030.07720.41
5.5.370.0000.08720.46
5.5.360.0200.07020.37
5.5.350.0000.09020.38
5.5.340.0170.07020.90
5.5.330.0000.08720.93
5.5.320.0000.08320.85
5.5.310.0070.05020.89
5.5.300.0030.05320.86
5.5.290.0030.08720.81
5.5.280.0130.08320.93
5.5.270.0130.08320.94
5.5.260.0070.05020.93
5.5.250.0100.08020.71
5.5.240.0070.07320.20
5.5.230.0100.07320.27
5.5.220.0070.04320.21
5.5.210.0070.07720.19
5.5.200.0100.07320.24
5.5.190.0070.08320.28
5.5.180.0100.07320.29
5.5.160.0030.07720.24
5.5.150.0030.08720.26
5.5.140.0030.04720.28
5.5.130.0000.08020.23
5.5.120.0170.07320.20
5.5.110.0100.07020.23
5.5.100.0030.09020.14
5.5.90.0070.07720.08
5.5.80.0070.07720.17
5.5.70.0100.07020.11
5.5.60.0030.08020.10
5.5.50.0070.07320.10
5.5.40.0070.07720.08
5.5.30.0030.07320.07
5.5.20.0130.07320.16
5.5.10.0030.07320.05
5.5.00.0100.04320.05
5.4.450.0100.07319.27
5.4.440.0100.07719.33
5.4.430.0000.07319.45
5.4.420.0030.07319.35
5.4.410.0070.07019.36
5.4.400.0100.07319.19
5.4.390.0100.07319.13
5.4.380.0100.06318.88
5.4.370.0070.07319.05
5.4.360.0030.08018.96
5.4.350.0100.05718.88
5.4.340.0030.07719.21
5.4.320.0000.08019.21
5.4.310.0070.08019.18
5.4.300.0100.05719.03
5.4.290.0100.07718.85
5.4.280.0130.06719.13
5.4.270.0030.08019.09
5.4.260.0170.06719.18
5.4.250.0100.05719.02
5.4.240.0070.07718.95
5.4.230.0100.06319.03
5.4.220.0070.07318.95
5.4.210.0030.07318.94
5.4.200.0030.07319.04
5.4.190.0130.07019.02
5.4.180.0130.07319.17
5.4.170.0130.06319.02
5.4.160.0070.07019.04
5.4.150.0130.07019.02
5.4.140.0030.07716.32
5.4.130.0100.07016.49
5.4.120.0100.06716.48
5.4.110.0000.07716.52
5.4.100.0070.07316.49
5.4.90.0100.06716.52
5.4.80.0070.05316.49
5.4.70.0070.03016.55
5.4.60.0030.03316.51
5.4.50.0070.03016.32
5.4.40.0000.06016.42
5.4.30.0000.03716.40
5.4.20.0030.03316.45
5.4.10.0030.04016.24
5.4.00.0030.03315.93
5.3.290.0030.08014.66
5.3.280.0130.06714.64
5.3.270.0030.08014.60
5.3.260.0030.07714.68
5.3.250.0170.06714.71
5.3.240.0000.08014.68
5.3.230.0000.08314.59
5.3.220.0070.07314.52
5.3.210.0170.05714.58
5.3.200.0130.06714.58
5.3.190.0100.07014.55
5.3.180.0170.06714.71
5.3.170.0100.03014.63
5.3.160.0070.05314.52
5.3.150.0030.05014.66
5.3.140.0130.05014.49
5.3.130.0100.03314.62
5.3.120.0100.03014.62
5.3.110.0000.05714.62
5.3.100.0130.02714.18
5.3.90.0030.04713.96
5.3.80.0130.02714.11
5.3.70.0000.05014.13
5.3.60.0030.07714.12
5.3.50.0000.03714.05
5.3.40.0170.06014.08
5.3.30.0000.08014.05
5.3.20.0030.05013.68
5.3.10.0000.03713.67
5.3.00.0000.06013.57
5.2.170.0100.02011.21
5.2.160.0070.06011.18
5.2.150.0030.03011.05
5.2.140.0000.07011.14
5.2.130.0070.05011.10
5.2.120.0070.04010.97
5.2.110.0030.05311.21
5.2.100.0000.03011.00
5.2.90.0000.03311.15
5.2.80.0070.04711.24
5.2.70.0070.05011.22
5.2.60.0070.05711.16
5.2.50.0000.03011.13
5.2.40.0000.03311.01
5.2.30.0000.03011.05
5.2.20.0000.03010.95
5.2.10.0000.03710.95
5.2.00.0030.02710.95
5.1.60.0030.04010.95
5.1.50.0000.02310.95
5.1.40.0070.05010.95
5.1.30.0030.02310.95
5.1.20.0000.04310.95
5.1.10.0030.02310.95
5.1.00.0000.05010.95
5.0.50.0030.02010.95
5.0.40.0000.02710.95
5.0.30.0000.03010.95
5.0.20.0000.02710.95
5.0.10.0000.02010.95
5.0.00.0000.02710.95
4.4.90.0030.01710.95
4.4.80.0070.01010.95
4.4.70.0000.03010.95
4.4.60.0000.01710.95
4.4.50.0000.03310.95
4.4.40.0000.03310.95
4.4.30.0000.03710.95
4.4.20.0000.03710.95
4.4.10.0000.03710.95
4.4.00.0000.02310.95
4.3.110.0000.02710.95
4.3.100.0030.01310.95
4.3.90.0030.01310.95
4.3.80.0000.02310.95
4.3.70.0000.02310.95
4.3.60.0000.02310.95
4.3.50.0000.01710.95
4.3.40.0000.03010.95
4.3.30.0030.01010.95
4.3.20.0000.02010.95
4.3.10.0000.01710.95
4.3.00.0000.01310.95

preferences:
50.82 ms | 401 KiB | 5 Q