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 implements AnswerInterface { function get(){ return $this->the(); } function the(){ return $this->answer(); } 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.0070.00716.75
8.3.50.0100.00817.35
8.3.40.0150.00018.69
8.3.30.0080.00818.79
8.3.20.0000.00818.85
8.3.10.0090.00020.51
8.3.00.0060.00319.38
8.2.180.0110.01117.00
8.2.170.0120.00922.96
8.2.160.0100.00721.02
8.2.150.0070.00024.18
8.2.140.0030.00524.66
8.2.130.0050.00226.16
8.2.120.0050.00319.09
8.2.110.0040.00419.31
8.2.100.0080.00417.72
8.2.90.0060.00319.50
8.2.80.0070.00019.26
8.2.70.0000.00817.63
8.2.60.0000.00817.93
8.2.50.0000.00818.07
8.2.40.0040.00418.16
8.2.30.0000.00718.12
8.2.20.0000.00817.72
8.2.10.0080.00017.81
8.2.00.0000.00717.80
8.1.280.0140.00725.92
8.1.270.0040.00424.66
8.1.260.0030.00526.35
8.1.250.0000.00728.09
8.1.240.0060.00623.86
8.1.230.0060.00622.73
8.1.220.0040.00417.77
8.1.210.0040.00718.77
8.1.200.0030.00717.35
8.1.190.0030.00617.64
8.1.180.0000.00818.10
8.1.170.0040.00418.87
8.1.160.0040.00418.88
8.1.150.0000.00718.60
8.1.140.0000.00817.46
8.1.130.0050.00317.79
8.1.120.0000.00717.43
8.1.110.0050.00217.31
8.1.100.0030.00417.46
8.1.90.0040.00417.43
8.1.80.0040.00417.46
8.1.70.0030.00317.44
8.1.60.0000.00717.59
8.1.50.0030.00617.45
8.1.40.0040.00417.47
8.1.30.0000.00717.58
8.1.20.0060.00317.71
8.1.10.0040.00417.57
8.1.00.0000.00817.52
8.0.300.0000.00720.11
8.0.290.0050.00216.75
8.0.280.0000.00818.36
8.0.270.0000.00817.30
8.0.260.0030.00318.46
8.0.250.0000.00717.05
8.0.240.0040.00416.93
8.0.230.0070.00016.95
8.0.220.0000.00716.86
8.0.210.0030.00316.97
8.0.200.0030.00317.08
8.0.190.0000.00817.02
8.0.180.0050.00316.94
8.0.170.0040.00416.98
8.0.160.0000.00716.84
8.0.150.0000.00916.95
8.0.140.0030.00616.78
8.0.130.0060.00013.37
8.0.120.0040.00416.90
8.0.110.0040.00416.84
8.0.100.0000.00816.97
8.0.90.0000.00716.86
8.0.80.0030.01316.93
8.0.70.0040.00417.07
8.0.60.0020.00516.91
8.0.50.0080.00016.75
8.0.30.0090.00917.15
8.0.20.0100.00917.21
8.0.10.0050.00217.07
8.0.00.0110.00816.89
7.4.330.0000.00512.89
7.4.320.0000.00616.61
7.4.300.0060.00016.63
7.4.290.0030.00316.43
7.4.280.0000.00816.52
7.4.270.0000.00716.65
7.4.260.0000.00513.27
7.4.250.0000.00916.45
7.4.240.0080.00016.36
7.4.230.0030.00316.50
7.4.220.0120.00616.56
7.4.210.0080.00716.52
7.4.200.0000.00716.42
7.4.190.0070.00016.55
7.4.160.0130.01016.36
7.4.150.0090.00916.69
7.4.140.0110.01116.58
7.4.130.0080.00816.53
7.4.120.0090.00716.52
7.4.110.0110.00616.71
7.4.100.0100.01316.72
7.4.90.0130.00416.58
7.4.80.0070.01019.39
7.4.70.0030.01416.43
7.4.60.0120.00616.58
7.4.50.0000.01216.65
7.4.40.0090.00616.49
7.4.30.0170.00016.52
7.4.00.0060.01215.02
7.3.330.0000.00613.23
7.3.320.0000.00513.20
7.3.310.0030.00316.37
7.3.300.0070.00016.23
7.3.290.0000.01516.35
7.3.280.0070.00816.35
7.3.270.0100.00716.39
7.3.260.0110.00616.38
7.3.250.0080.01016.36
7.3.240.0060.01016.51
7.3.230.0100.00716.53
7.3.210.0070.01016.49
7.3.200.0090.00616.55
7.3.190.0000.02016.43
7.3.180.0060.00916.37
7.3.170.0120.01216.32
7.3.160.0060.01216.44
7.3.120.0120.00314.98
7.2.330.0180.00616.42
7.2.320.0120.00916.58
7.2.310.0090.01216.34
7.2.300.0110.00616.41
7.2.290.0080.00816.51
7.2.80.0040.01416.67
7.2.60.0060.01016.53
7.2.00.0030.00619.29
7.1.200.0040.01115.84
7.1.100.0080.00417.87
7.1.70.0030.00617.28
7.1.60.0040.01819.40
7.1.50.0040.00716.84
7.1.00.0100.06322.35
7.0.200.0500.00314.43
7.0.140.0070.06321.95
7.0.120.0000.03322.15
7.0.60.0130.05019.96
7.0.50.0100.07717.88
7.0.40.0170.07720.13
7.0.30.0270.08020.16
7.0.20.0200.07720.10
7.0.10.0170.05020.05
7.0.00.0030.05020.14
5.6.280.0000.07321.11
5.6.210.0170.07020.76
5.6.200.0070.06318.19
5.6.190.0070.09020.59
5.6.180.0330.05320.44
5.6.170.0230.07020.57
5.6.160.0230.06020.52
5.6.150.0130.08018.24
5.6.140.0100.07718.15
5.6.130.0070.08018.16
5.6.120.0130.08321.06
5.6.110.0100.08020.90
5.6.100.0070.03721.07
5.6.90.0070.07721.11
5.6.80.0030.04720.51
5.6.70.0270.07320.51
5.5.350.0330.05020.52
5.5.340.0070.08018.02
5.5.330.0100.03720.21
5.5.320.0200.06720.57
5.5.310.0370.07020.34
5.5.300.0030.08317.98
5.5.290.0130.05017.98
5.5.280.0100.03320.85
5.5.270.0100.06020.78
5.5.260.0170.06320.65
5.5.250.0030.05720.70
5.5.240.0030.05720.36
5.4.450.0070.08019.49
5.4.440.0100.08019.48
5.4.430.0000.04319.40
5.4.420.0130.06719.57
5.4.410.0130.07019.31
5.4.400.0130.06718.92
5.4.390.0070.07318.98
5.4.380.0100.06719.24
5.4.370.0100.03319.15
5.4.360.0070.04319.07
5.4.350.0030.06019.17
5.4.340.0130.06719.20
5.4.320.0070.04019.25
5.4.310.0030.04718.94
5.4.300.0030.08018.97
5.4.290.0100.06019.15
5.4.280.0130.07719.24
5.4.270.0000.08318.85
5.4.260.0170.06719.07
5.4.250.0030.07719.20
5.4.240.0030.06719.23
5.4.230.0130.06719.23
5.4.220.0000.06019.11
5.4.210.0100.08319.15
5.4.200.0130.05719.14
5.4.190.0030.04319.15
5.4.180.0030.05019.06
5.4.170.0130.04318.86
5.4.160.0030.03718.90
5.4.150.0000.05019.13
5.4.140.0130.06316.39
5.4.130.0130.06316.39
5.4.120.0070.04316.59
5.4.110.0100.05016.39
5.4.100.0100.04016.43
5.4.90.0030.05716.52
5.4.80.0000.04716.50
5.4.70.0070.07316.37
5.4.60.0100.07016.37
5.4.50.0000.04016.42
5.4.40.0030.06716.35
5.4.30.0000.07716.36
5.4.20.0070.04716.40
5.4.10.0030.04016.39
5.4.00.0030.03315.82
5.3.290.0030.04014.67
5.3.280.0000.08014.66
5.3.270.0030.08314.62
5.3.260.0030.07714.63
5.3.250.0100.06014.76
5.3.240.0030.08014.68
5.3.230.0070.05014.67
5.3.220.0100.06314.63
5.3.210.0170.07014.66
5.3.200.0100.06314.63
5.3.190.0100.07314.58
5.3.180.0100.08314.63
5.3.170.0070.07714.58
5.3.160.0000.04014.61
5.3.150.0000.04314.63
5.3.140.0000.04014.61
5.3.130.0070.07714.70
5.3.120.0070.05014.56
5.3.110.0100.07014.58
5.3.100.0030.04314.04
5.3.90.0070.04013.91
5.3.80.0100.04713.95
5.3.70.0000.04313.99
5.3.60.0030.04014.03
5.3.50.0030.07013.97
5.3.40.0070.03713.96
5.3.30.0030.07313.94
5.3.20.0070.06713.70
5.3.10.0030.04713.66
5.3.00.0070.05713.64
5.2.170.0100.05711.16
5.2.160.0070.05011.17
5.2.150.0100.05011.21
5.2.140.0030.04711.10
5.2.130.0070.04011.07
5.2.120.0030.05311.27
5.2.110.0070.06011.26
5.2.100.0070.05311.28
5.2.90.0070.05311.00
5.2.80.0100.04311.16
5.2.70.0000.04711.07
5.2.60.0070.02711.06
5.2.50.0130.05711.09
5.2.40.0070.06010.96
5.2.30.0070.03710.98
5.2.20.0100.03010.94
5.2.10.0030.06010.90
5.2.00.0070.04010.88
5.1.60.0030.03710.01
5.1.50.0100.0279.91
5.1.40.0130.0479.90
5.1.30.0070.05710.23
5.1.20.0000.05310.32
5.1.10.0130.03010.05
5.1.00.0000.05710.04
5.0.50.0000.0438.63
5.0.40.0070.0438.42
5.0.30.0070.0638.29
5.0.20.0000.0508.21
5.0.10.0000.0478.18
5.0.00.0070.0608.32
4.4.90.0030.0207.66
4.4.80.0000.0377.66
4.4.70.0000.0377.66
4.4.60.0030.0377.66
4.4.50.0000.0377.66
4.4.40.0030.0277.66
4.4.30.0000.0177.66
4.4.20.0000.0407.66
4.4.10.0000.0337.66
4.4.00.0000.0577.66
4.3.110.0000.0207.66
4.3.100.0030.0307.66
4.3.90.0030.0137.66
4.3.80.0000.0577.66
4.3.70.0070.0307.66
4.3.60.0000.0377.66
4.3.50.0000.0277.66
4.3.40.0100.0437.66
4.3.30.0000.0337.66
4.3.20.0000.0407.66
4.3.10.0000.0377.66
4.3.00.0000.0377.66

preferences:
42.88 ms | 401 KiB | 5 Q