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 { public function __toString() { return "4"; } public function get() { return $this;} public function the() { return $this;} public function answer() { return $this;} } // 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.40.0140.00718.89
8.3.30.0100.00719.21
8.3.20.0080.00020.11
8.3.10.0070.00022.06
8.3.00.0070.00022.44
8.2.170.0070.01022.96
8.2.160.0100.01018.88
8.2.150.0070.00024.18
8.2.140.0040.00424.66
8.2.130.0110.00726.16
8.2.120.0000.00919.36
8.2.110.0030.00622.15
8.2.100.0030.00919.64
8.2.90.0030.00619.05
8.2.80.0050.00318.04
8.2.70.0030.00517.48
8.2.60.0050.00318.01
8.2.50.0030.00618.07
8.2.40.0000.00819.88
8.2.30.0050.00318.08
8.2.20.0000.00717.53
8.2.10.0030.00517.75
8.2.00.0040.00417.70
8.1.270.0040.00422.24
8.1.260.0030.00626.35
8.1.250.0060.00328.09
8.1.240.0040.00424.02
8.1.230.0000.01119.15
8.1.220.0050.00317.74
8.1.210.0000.00818.77
8.1.200.0040.00417.23
8.1.190.0080.00017.54
8.1.180.0060.00318.73
8.1.170.0000.00918.69
8.1.160.0030.00322.01
8.1.150.0040.00418.55
8.1.140.0000.00717.45
8.1.130.0050.00317.81
8.1.120.0000.00717.49
8.1.110.0050.00217.37
8.1.100.0000.00817.38
8.1.90.0040.00417.46
8.1.80.0000.00817.45
8.1.70.0080.00017.35
8.1.60.0080.00017.63
8.1.50.0040.00417.40
8.1.40.0030.00617.48
8.1.30.0030.00617.62
8.1.20.0040.00417.57
8.1.10.0040.00417.57
8.1.00.0000.00917.52
8.0.300.0070.00018.77
8.0.290.0000.00717.28
8.0.280.0000.00718.49
8.0.270.0040.00417.25
8.0.260.0030.00316.82
8.0.250.0000.00717.00
8.0.240.0040.00317.04
8.0.230.0050.00217.03
8.0.220.0060.00016.84
8.0.210.0030.00516.86
8.0.200.0050.00216.99
8.0.190.0040.00416.98
8.0.180.0040.00416.90
8.0.170.0000.00816.98
8.0.160.0000.00716.81
8.0.150.0000.00716.81
8.0.140.0000.00716.91
8.0.130.0040.00413.45
8.0.120.0030.00516.97
8.0.110.0000.00816.94
8.0.100.0040.00416.88
8.0.90.0040.00417.00
8.0.80.0090.01216.91
8.0.70.0000.00716.77
8.0.60.0000.00816.80
8.0.50.0040.00416.90
8.0.30.0110.00816.94
8.0.20.0130.00717.40
8.0.10.0040.00417.04
8.0.00.0090.01116.91
7.4.330.0060.00015.00
7.4.320.0030.00316.43
7.4.300.0040.00416.52
7.4.290.0090.00016.51
7.4.280.0040.00416.48
7.4.270.0040.00416.61
7.4.260.0000.00716.38
7.4.250.0040.00416.43
7.4.240.0010.00616.50
7.4.230.0030.00316.41
7.4.220.0110.00716.45
7.4.210.0100.00616.57
7.4.200.0000.00716.70
7.4.190.0040.00216.50
7.4.160.0060.01216.47
7.4.150.0090.00917.40
7.4.140.0130.00517.86
7.4.130.0130.00616.63
7.4.120.0100.00716.51
7.4.110.0140.00716.54
7.4.100.0120.00916.49
7.4.90.0100.00716.53
7.4.80.0110.00619.39
7.4.70.0090.00916.58
7.4.60.0080.01216.58
7.4.50.0040.00416.47
7.4.40.0040.00422.77
7.4.30.0110.00616.51
7.4.00.0040.01115.09
7.3.330.0040.00413.23
7.3.320.0060.00013.32
7.3.310.0070.00016.21
7.3.300.0060.00316.35
7.3.290.0090.00916.37
7.3.280.0090.00616.37
7.3.270.0000.01617.40
7.3.260.0140.00316.57
7.3.250.0060.01216.42
7.3.240.0030.01316.55
7.3.230.0060.01216.62
7.3.210.0070.01016.34
7.3.200.0150.00919.39
7.3.190.0070.01016.38
7.3.180.0100.00616.53
7.3.170.0090.00916.44
7.3.160.0030.01216.52
7.3.120.0110.00415.01
7.2.330.0110.00716.87
7.2.320.0100.01216.86
7.2.310.0030.01316.86
7.2.300.0140.00416.68
7.2.290.0090.00916.36
7.2.60.0070.00716.96
7.2.00.0000.01219.64
7.1.200.0140.00515.57
7.1.100.0030.00718.13
7.1.70.0030.00617.05
7.1.60.0100.01419.82
7.1.50.0030.00916.97
7.1.00.0070.03022.42
7.0.200.0000.00816.79
7.0.140.0070.07022.18
7.0.60.0030.08319.91
7.0.50.0030.09017.93
7.0.40.0130.06320.39
7.0.30.0230.08320.09
7.0.20.0400.07320.10
7.0.10.0000.04720.09
7.0.00.0030.08320.13
5.6.280.0070.07020.93
5.6.210.0100.07020.54
5.6.200.0030.05718.15
5.6.190.0030.05020.52
5.6.180.0430.05720.61
5.6.170.0200.05020.51
5.6.160.0100.08020.48
5.6.150.0030.06018.22
5.6.140.0200.07318.28
5.6.130.0030.08318.18
5.6.120.0100.04721.04
5.6.110.0070.07721.01
5.6.100.0130.07721.05
5.6.90.0100.04721.10
5.6.80.0130.08020.38
5.5.350.0230.05720.33
5.5.340.0000.04318.02
5.5.330.0070.06020.47
5.5.320.0330.08020.30
5.5.310.0330.07020.30
5.5.300.0000.04717.94
5.5.290.0100.08018.02
5.5.280.0130.07720.81
5.5.270.0100.04020.89
5.5.260.0130.07320.77
5.5.250.0070.04020.56
5.5.240.0070.06320.36
5.4.450.0230.06319.48
5.4.440.0270.04319.31
5.4.430.0330.06719.64
5.4.420.0300.07319.31
5.4.410.0330.07319.51
5.4.400.0370.06019.06
5.4.390.0370.06019.13
5.4.380.0330.07018.85
5.4.370.0300.03719.09
5.4.360.0230.05719.24
5.4.350.0500.05018.95
5.4.340.0270.06019.16
5.4.320.0270.07319.09
5.4.310.0230.04319.20
5.4.300.0330.06718.99
5.4.290.0300.07319.14
5.4.280.0230.05719.04
5.4.270.0330.05319.08
5.4.260.0300.08319.31
5.4.250.0300.07019.05
5.4.240.0230.08019.09
5.4.230.0270.07319.17
5.4.220.0270.07318.97
5.4.210.0330.04319.25
5.4.200.0270.06319.14
5.4.190.0330.06019.21
5.4.180.0270.05019.15
5.4.170.0330.07019.21
5.4.160.0400.06718.96
5.4.150.0200.04718.85
5.4.140.0230.04716.41
5.4.130.0270.04316.39
5.4.120.0300.06016.56
5.4.110.0370.05316.24
5.4.100.0270.05016.59
5.4.90.0270.03316.63
5.4.80.0230.04716.59
5.4.70.0200.05716.39
5.4.60.0270.05016.43
5.4.50.0230.05316.51
5.4.40.0300.06716.52
5.4.30.0230.07316.51
5.4.20.0230.07716.52
5.4.10.0300.07316.34
5.4.00.0300.04715.80
5.3.290.0330.03714.70
5.3.280.0300.06714.57
5.3.270.0200.05014.70
5.3.260.0300.07314.61
5.3.250.0300.03314.83
5.3.240.0230.04714.73
5.3.230.0300.05314.51
5.3.220.0300.04314.60
5.3.210.0300.06014.48
5.3.200.0370.06314.66
5.3.190.0230.05014.56
5.3.180.0270.04714.47
5.3.170.0200.04314.50
5.3.160.0330.06714.69
5.3.150.0330.05014.57
5.3.140.0430.06314.66
5.3.130.0400.05314.78
5.3.120.0270.06314.55
5.3.110.0270.04714.79
5.3.100.0300.06014.13
5.3.90.0270.04014.02
5.3.80.0270.03713.93
5.3.70.0230.03713.93
5.3.60.0230.07313.94
5.3.50.0200.04714.10
5.3.40.0230.04714.18
5.3.30.0330.05013.89
5.3.20.0230.06313.68
5.3.10.0270.07313.67
5.3.00.0430.05713.56
5.2.170.0230.05311.71
5.2.160.0270.06011.71
5.2.150.0330.05711.71
5.2.140.0200.04711.71
5.2.130.0200.06011.71
5.2.120.0200.03011.71
5.2.110.0230.05311.71
5.2.100.0300.05311.71
5.2.90.0230.05711.71
5.2.80.0270.04011.71
5.2.70.0230.06011.71
5.2.60.0200.05711.71
5.2.50.0300.05011.71
5.2.40.0200.05011.71
5.2.30.0230.05711.71
5.2.20.0170.06011.71
5.2.10.0270.04311.71
5.2.00.0200.05011.71
5.1.60.0230.05011.71
5.1.50.0170.04311.71
5.1.40.0300.04011.71
5.1.30.0200.05711.71
5.1.20.0200.02711.71
5.1.10.0130.03011.71
5.1.00.0200.03011.71
5.0.50.0100.03711.71
5.0.40.0130.03711.71
5.0.30.0100.06311.71
5.0.20.0070.03011.71
5.0.10.0130.03311.71
5.0.00.0130.06011.71
4.4.90.0100.03011.71
4.4.80.0100.03311.71
4.4.70.0100.04011.71
4.4.60.0070.02311.71
4.4.50.0130.02711.71
4.4.40.0170.03311.71
4.4.30.0170.01711.71
4.4.20.0070.02011.71
4.4.10.0230.01711.71
4.4.00.0070.03311.71
4.3.110.0100.03311.71
4.3.100.0130.02711.71
4.3.90.0130.03311.71
4.3.80.0070.04711.71
4.3.70.0130.02011.71
4.3.60.0070.03711.71
4.3.50.0100.03311.71
4.3.40.0070.02311.71
4.3.30.0000.02011.71
4.3.20.0070.01311.71
4.3.10.0030.02011.71
4.3.00.0030.01311.71

preferences:
40.08 ms | 400 KiB | 5 Q