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(); var_dump($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 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.0100.00718.55
8.3.50.0110.00722.00
8.3.40.0150.00418.68
8.3.30.0140.00319.08
8.3.20.0070.00020.29
8.3.10.0110.00422.09
8.3.00.0090.00022.34
8.2.180.0180.00016.47
8.2.170.0120.00322.96
8.2.160.0060.00920.95
8.2.150.0040.01124.18
8.2.140.0080.00024.66
8.2.130.0070.01026.16
8.2.120.0040.00419.36
8.2.110.0030.00620.57
8.2.100.0080.00417.84
8.2.90.0040.00417.91
8.2.80.0060.00317.97
8.2.70.0000.00817.50
8.2.60.0040.00417.80
8.2.50.0000.00818.07
8.2.40.0060.00318.16
8.2.30.0070.00018.07
8.2.20.0000.00817.75
8.2.10.0060.00319.46
8.2.00.0050.00317.79
8.1.280.0090.01225.92
8.1.270.0060.00323.87
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0110.00020.64
8.1.230.0070.00420.96
8.1.220.0050.00317.74
8.1.210.0040.00419.00
8.1.200.0060.00317.35
8.1.190.0050.00317.51
8.1.180.0060.00318.71
8.1.170.0000.00818.63
8.1.160.0040.00422.07
8.1.150.0000.00718.65
8.1.140.0040.00417.42
8.1.130.0030.00317.75
8.1.120.0040.00417.44
8.1.110.0040.00417.49
8.1.100.0000.00717.49
8.1.90.0000.00717.46
8.1.80.0000.00717.53
8.1.70.0040.00417.40
8.1.60.0000.00817.59
8.1.50.0070.00017.59
8.1.40.0000.00817.49
8.1.30.0000.00817.66
8.1.20.0000.00817.73
8.1.10.0050.00317.56
8.1.00.0030.00517.57
8.0.300.0070.00019.93
8.0.290.0040.00417.16
8.0.280.0000.00818.45
8.0.270.0000.00717.32
8.0.260.0000.00616.91
8.0.250.0070.00017.05
8.0.240.0020.00517.06
8.0.230.0000.00717.03
8.0.220.0030.00317.02
8.0.210.0030.00317.01
8.0.200.0040.00317.03
8.0.190.0110.00316.99
8.0.180.0000.00816.88
8.0.170.0040.00416.97
8.0.160.0070.00017.02
8.0.150.0040.00416.79
8.0.140.0040.00416.81
8.0.130.0060.00013.39
8.0.120.0040.00416.96
8.0.110.0050.00317.04
8.0.100.0050.00216.96
8.0.90.0040.00416.86
8.0.80.0040.01216.96
8.0.70.0050.00217.03
8.0.60.0070.00016.77
8.0.50.0040.00416.91
8.0.30.0060.01216.92
8.0.20.0080.01017.40
8.0.10.0060.00316.94
8.0.00.0110.00816.83
7.4.330.0050.00015.10
7.4.320.0000.00616.61
7.4.300.0070.00016.44
7.4.290.0000.00716.38
7.4.280.0030.00316.52
7.4.270.0060.00016.53
7.4.260.0030.00316.57
7.4.250.0040.00416.42
7.4.240.0020.00516.56
7.4.230.0000.00716.57
7.4.220.0090.00916.59
7.4.210.0060.00816.66
7.4.200.0070.00016.34
7.4.190.0000.00716.63
7.4.160.0080.00816.33
7.4.150.0090.00917.40
7.4.140.0090.00917.86
7.4.130.0110.00616.54
7.4.120.0090.00916.60
7.4.110.0130.01016.65
7.4.100.0080.00916.58
7.4.90.0060.01216.45
7.4.80.0100.01019.39
7.4.70.0070.01016.56
7.4.60.0110.00716.46
7.4.50.0040.00416.38
7.4.40.0110.00422.77
7.4.30.0110.01116.57
7.4.00.0070.01015.15
7.3.330.0030.00313.32
7.3.320.0030.00313.40
7.3.310.0070.00016.36
7.3.300.0030.00316.29
7.3.290.0030.01616.39
7.3.280.0120.00216.35
7.3.270.0060.01117.40
7.3.260.0030.01416.33
7.3.250.0090.01216.39
7.3.240.0100.01316.47
7.3.230.0110.00716.39
7.3.210.0130.00316.58
7.3.200.0050.01219.39
7.3.190.0130.00616.38
7.3.180.0120.00316.43
7.3.170.0130.00916.32
7.3.160.0090.00916.29
7.3.120.0070.00414.84
7.2.330.0070.01116.71
7.2.320.0040.01616.36
7.2.310.0160.00716.45
7.2.300.0090.00616.35
7.2.290.0090.00616.69
7.2.60.0000.01516.86
7.2.00.0070.00719.24
7.1.200.0030.01015.71
7.1.70.0000.00717.31
7.1.60.0110.00017.26
7.1.50.0050.00516.93
7.1.00.0130.06022.33
7.0.200.0030.01016.52
7.0.140.0130.06022.12
7.0.60.0130.05720.07
7.0.50.0130.07317.70
7.0.40.0100.08720.21
7.0.30.0300.04020.06
7.0.20.0170.09020.22
7.0.10.0030.08720.22
7.0.00.0100.06320.08
5.6.280.0000.07321.01
5.6.210.0200.07320.48
5.6.200.0130.08018.19
5.6.190.0070.08320.39
5.6.180.0270.04020.39
5.6.170.0230.06320.58
5.6.160.0030.05320.50
5.6.150.0030.07018.12
5.6.140.0230.06718.14
5.6.130.0170.07718.28
5.6.120.0100.05720.91
5.6.110.0070.08720.97
5.6.100.0130.07320.98
5.6.90.0100.04721.09
5.6.80.0030.08320.54
5.5.350.3170.04020.46
5.5.340.0100.07718.01
5.5.330.0000.07020.28
5.5.320.0330.06320.27
5.5.310.0230.05320.27
5.5.300.0030.04017.95
5.5.290.0100.07717.98
5.5.280.0030.05320.74
5.5.270.0030.08720.85
5.5.260.0100.06720.80
5.5.250.0100.08320.70
5.5.240.0070.05320.25
5.4.450.0600.04319.28
5.4.440.0570.04319.32
5.4.430.0600.05019.34
5.4.420.0570.04019.54
5.4.410.0530.03319.07
5.4.400.0530.04719.31
5.4.390.0600.03719.24
5.4.380.0130.06018.62
5.4.370.0170.06018.70
5.4.360.0430.06018.54
5.4.350.0300.05018.73
5.4.340.0200.06018.58
5.4.320.0060.03712.51
5.4.310.0040.03912.50
5.4.300.0080.04012.52
5.4.290.0060.03812.50
5.4.280.0060.03412.41
5.4.270.0040.03912.41
5.4.260.0070.07718.62
5.4.250.0170.07718.77
5.4.240.0100.06018.78
5.4.230.0070.08018.61
5.4.220.0070.05718.96
5.4.210.0130.05719.05
5.4.200.0100.07718.96
5.4.190.0200.04718.61
5.4.180.0070.07318.70
5.4.170.0170.04318.94
5.4.160.0170.04719.05
5.4.150.0070.06018.61
5.4.140.0070.05316.64
5.4.130.0070.05016.64
5.4.120.0130.04716.60
5.4.110.0100.06016.48
5.4.100.0170.05016.43
5.4.90.0030.06016.58
5.4.80.0070.05316.36
5.4.70.0070.05316.41
5.4.60.0130.06016.55
5.4.50.0130.05316.50
5.4.40.0100.04716.37
5.4.30.0070.05016.35
5.4.20.0000.05716.34
5.4.10.0070.05716.46
5.4.00.0070.04715.84
5.3.290.0040.04212.80
5.3.280.0170.05014.69
5.3.270.0100.05314.68
5.3.260.0070.05314.70
5.3.250.0070.07014.79
5.3.240.0170.04314.70
5.3.230.0130.05314.74
5.3.220.0070.05714.64
5.3.210.0000.08314.64
5.3.200.0100.04714.48
5.3.190.0230.03314.74
5.3.180.0130.04314.65
5.3.170.0070.05014.66
5.3.160.0070.07014.70
5.3.150.0130.04314.55
5.3.140.0030.05314.48
5.3.130.0170.04314.69
5.3.120.0100.05314.65
5.3.110.0070.07014.72
5.3.100.0100.05014.04
5.3.90.0070.04714.20
5.3.80.0130.04314.25
5.3.70.0100.04314.20
5.3.60.0100.04713.84
5.3.50.0030.05013.97
5.3.40.0100.04314.04
5.3.30.0000.05313.90
5.3.20.0030.05013.62
5.3.10.0100.05013.61
5.3.00.0070.05313.86
5.2.170.0100.03311.12
5.2.160.0030.04311.05
5.2.150.0170.04011.37
5.2.140.0030.04311.14
5.2.130.0070.04011.12
5.2.120.0070.03711.08
5.2.110.0130.03011.19
5.2.100.0100.03711.29
5.2.90.0000.04711.08
5.2.80.0100.03711.17
5.2.70.0070.04011.27
5.2.60.0000.04311.12
5.2.50.0100.05710.93
5.2.40.0070.03711.09
5.2.30.0070.04310.96
5.2.20.0030.04010.97
5.2.10.0100.04010.87
5.2.00.0100.04310.81
5.1.60.0030.03310.25
5.1.50.0070.04710.16
5.1.40.0070.0309.82
5.1.30.0100.04010.29
5.1.20.0000.04010.44
5.1.10.0030.03710.27
5.1.00.0130.02710.14
5.0.50.0070.0278.80
5.0.40.0030.0278.62
5.0.30.0030.0538.29
5.0.20.0000.0308.45
5.0.10.0000.0308.10
5.0.00.0030.0438.16
4.4.90.0000.0237.01
4.4.80.0000.0207.01
4.4.70.0000.0237.01
4.4.60.0030.0207.01
4.4.50.0030.0207.01
4.4.40.0070.0277.01
4.4.30.0000.0237.01
4.4.20.0000.0237.01
4.4.10.0000.0337.01
4.4.00.0070.0307.01
4.3.110.0070.0177.01
4.3.100.0030.0207.01
4.3.90.0070.0177.01
4.3.80.0000.0377.01
4.3.70.0070.0177.01
4.3.60.0030.0307.01
4.3.50.0070.0177.01
4.3.40.0030.0307.01
4.3.30.0000.0337.01
4.3.20.0000.0237.01
4.3.10.0000.0307.01
4.3.00.0030.01714.49

preferences:
46.29 ms | 401 KiB | 5 Q