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 __construct() { } public function get() { return $this; } public function the() { return $this; } public function answer() { return $this; } public function __toString() { 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.0040.01816.75
8.3.50.0140.00522.06
8.3.40.0070.00718.58
8.3.30.0170.00319.13
8.3.20.0080.00020.18
8.3.10.0000.00921.90
8.3.00.0000.00819.38
8.2.180.0040.01218.51
8.2.170.0100.00722.96
8.2.160.0090.00620.35
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0000.00726.16
8.2.120.0040.00419.66
8.2.110.0110.00720.89
8.2.100.0060.00617.63
8.2.90.0000.00819.08
8.2.80.0000.00917.97
8.2.70.0030.00617.59
8.2.60.0030.00718.04
8.2.50.0090.00318.07
8.2.40.0000.00819.66
8.2.30.0040.00418.07
8.2.20.0040.00417.57
8.2.10.0000.00718.11
8.2.00.0040.00417.63
8.1.280.0090.00925.92
8.1.270.0000.00819.02
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0000.00923.92
8.1.230.0070.00418.84
8.1.220.0030.00517.79
8.1.210.0040.00418.77
8.1.200.0090.00017.47
8.1.190.0000.00817.22
8.1.180.0090.00018.10
8.1.170.0040.00420.38
8.1.160.0070.00022.02
8.1.150.0070.00018.93
8.1.140.0070.00017.41
8.1.130.0000.00717.86
8.1.120.0050.00217.50
8.1.110.0030.00517.38
8.1.100.0000.00717.48
8.1.90.0030.00517.50
8.1.80.0050.00217.35
8.1.70.0030.00317.45
8.1.60.0040.00417.64
8.1.50.0040.00417.48
8.1.40.0040.00417.40
8.1.30.0030.00617.62
8.1.20.0000.00717.56
8.1.10.0040.00417.52
8.1.00.0040.00417.45
8.0.300.0050.00218.77
8.0.290.0040.00416.88
8.0.280.0070.00018.45
8.0.270.0000.00717.36
8.0.260.0000.00617.36
8.0.250.0030.00316.93
8.0.240.0000.00617.06
8.0.230.0030.00317.02
8.0.220.0030.00316.96
8.0.210.0000.00816.97
8.0.200.0040.00416.87
8.0.190.0070.00017.01
8.0.180.0000.00717.00
8.0.170.0090.00016.94
8.0.160.0040.00416.93
8.0.150.0040.00416.86
8.0.140.0070.00016.97
8.0.130.0000.00613.42
8.0.120.0030.00616.92
8.0.110.0020.00517.00
8.0.100.0040.00417.05
8.0.90.0030.00316.90
8.0.80.0060.01016.93
8.0.70.0040.00416.78
8.0.60.0000.00716.89
8.0.50.0040.00416.84
8.0.30.0100.01117.07
8.0.20.0150.01317.40
8.0.10.0070.00017.19
8.0.00.0100.00616.83
7.4.330.0020.00215.07
7.4.320.0000.00616.52
7.4.300.0000.00916.51
7.4.290.0000.00716.58
7.4.280.0040.00416.50
7.4.270.0030.00316.61
7.4.260.0030.00316.48
7.4.250.0040.00416.41
7.4.240.0040.00316.48
7.4.230.0000.00716.71
7.4.220.0090.01016.53
7.4.210.0100.00716.51
7.4.200.0040.00416.48
7.4.160.0090.00616.50
7.4.150.0090.00917.40
7.4.140.0090.00917.86
7.4.130.0110.00916.51
7.4.120.0180.00416.46
7.4.110.0100.00716.56
7.4.100.0030.01416.46
7.4.90.0100.00716.57
7.4.80.0030.01319.39
7.4.70.0070.01016.49
7.4.60.0130.00316.47
7.4.50.0060.00316.34
7.4.40.0060.01016.62
7.4.30.0090.00916.47
7.4.00.0030.00714.92
7.3.330.0000.00613.30
7.3.320.0070.00413.16
7.3.310.0030.00316.19
7.3.300.0000.00616.34
7.3.290.0070.00016.31
7.3.280.0120.00816.32
7.3.270.0110.00717.40
7.3.260.0140.00316.42
7.3.250.0180.00216.36
7.3.240.0110.00616.45
7.3.230.0080.00816.39
7.3.210.0100.01316.21
7.3.200.0060.01319.39
7.3.190.0100.00616.42
7.3.180.0070.01016.38
7.3.170.0100.00716.59
7.3.160.0100.00616.46
7.2.330.0110.00616.52
7.2.320.0060.01516.67
7.2.310.0070.01016.64
7.2.300.0160.00616.64
7.2.290.0210.00316.80
7.2.60.0000.01416.63
7.2.00.0040.00819.63
7.1.200.0070.01015.62
7.1.100.0030.00617.82
7.1.70.0050.00217.15
7.1.60.0030.02019.46
7.1.50.0260.01034.76
7.1.00.0030.07722.33
7.0.200.0030.00716.82
7.0.140.0030.04322.08
7.0.120.0000.04321.98
7.0.110.0070.03722.05
7.0.100.0030.04022.02
7.0.90.0030.04021.93
7.0.80.0070.04022.01
7.0.70.0000.04322.14
7.0.60.0030.04022.04
7.0.50.0100.03022.02
7.0.40.0000.07320.06
7.0.30.0030.06720.12
7.0.20.0030.03720.04
7.0.10.0000.06720.00
7.0.00.0000.05020.01
5.6.280.0070.06720.83
5.6.270.0030.04021.08
5.6.260.0000.04720.73
5.6.250.0100.04720.94
5.6.240.0100.04021.02
5.6.230.0070.04020.96
5.6.220.0000.04320.98
5.6.210.0030.04020.90
5.6.200.0030.04020.89
5.6.190.0070.04020.76
5.6.180.0030.06720.96
5.6.170.0000.08320.95
5.6.160.0030.07020.98
5.6.150.0100.04720.88
5.6.140.0100.04720.94
5.6.130.0130.08020.98
5.6.120.0070.07020.95
5.6.110.0100.07320.87
5.6.100.0130.04320.88
5.6.90.0070.08720.77
5.6.80.0070.07720.39
5.6.70.0000.07720.16
5.6.60.0000.08320.16
5.6.50.0100.04720.41
5.6.40.0070.09020.30
5.6.30.0070.08720.37
5.6.20.0000.08020.22
5.6.10.0130.05720.24
5.6.00.0070.07020.04
5.5.380.0000.04317.70
5.5.370.0030.04017.48
5.5.360.0100.03317.59
5.5.350.0070.07317.54
5.5.340.0070.03718.07
5.5.330.0070.07318.05
5.5.320.0070.07318.13
5.5.310.0000.04317.91
5.5.300.0100.08017.95
5.5.290.0000.07317.93
5.5.280.0000.05718.09
5.5.270.0030.06018.24
5.5.260.0100.07018.04
5.5.250.0100.07317.94
5.5.240.0000.07317.61
5.5.230.0030.05717.29
5.5.220.0000.03717.59
5.5.210.0030.07717.47
5.5.200.0100.07717.26
5.5.190.0130.06317.57
5.5.180.0100.06317.47
5.5.160.0100.06317.45
5.5.150.0070.06717.17
5.5.140.0070.05017.42
5.5.130.0030.07017.18
5.5.120.0000.08017.28
5.5.110.0070.07317.56
5.5.100.0000.06317.21
5.5.90.0100.05017.16
5.5.80.0030.07317.21
5.5.70.0130.03717.29
5.5.60.0070.06717.33
5.5.50.0070.07317.45
5.5.40.0030.08017.29
5.5.30.0000.07317.07
5.5.20.0030.04717.32
5.5.10.0000.08717.15
5.5.00.0100.03717.07
5.4.450.0070.03319.52
5.4.440.0070.07319.59
5.4.430.0170.05719.41
5.4.420.0070.07719.29
5.4.410.0070.05719.10
5.4.400.0030.06019.09
5.4.390.0070.07318.98
5.4.380.0000.07718.98
5.4.370.0030.04319.09
5.4.360.0230.04019.12
5.4.350.0100.06019.04
5.4.340.0030.04319.13
5.4.320.0070.05318.90
5.4.310.0070.06718.96
5.4.300.0070.04319.26
5.4.290.0070.06318.95
5.4.280.0070.08019.17
5.4.270.0030.05718.89
5.4.260.0030.03719.28
5.4.250.0030.04719.13
5.4.240.0070.04319.28
5.4.230.0100.05018.97
5.4.220.0030.03718.97
5.4.210.0100.07018.94
5.4.200.0000.07718.96
5.4.190.0070.04719.04
5.4.180.0030.04319.11
5.4.170.0030.05318.93
5.4.160.0000.04019.06
5.4.150.0070.06018.94
5.4.140.0170.03016.63
5.4.130.0030.04316.34
5.4.120.0130.05716.42
5.4.110.0070.07316.41
5.4.100.0030.03716.50
5.4.90.0170.06716.51
5.4.80.0100.05316.64
5.4.70.0070.05016.46
5.4.60.0030.04316.36
5.4.50.0000.05316.36
5.4.40.0030.06016.34
5.4.30.0070.03716.39
5.4.20.0030.04316.46
5.4.10.0000.04716.23
5.4.00.0070.05715.73
5.3.290.0130.05314.70
5.3.280.0030.07014.75
5.3.270.0100.06314.75
5.3.260.0000.04014.48
5.3.250.0070.05014.75
5.3.240.0070.06714.65
5.3.230.0130.04314.46
5.3.220.0070.06714.56
5.3.210.0070.06014.56
5.3.200.0100.05014.54
5.3.190.0030.05714.59
5.3.180.0030.07014.57
5.3.170.0030.04714.59
5.3.160.0000.06714.59
5.3.150.0000.04014.54
5.3.140.0030.07314.56
5.3.130.0070.04014.69
5.3.120.0070.04314.57
5.3.110.0030.06014.79
5.3.100.0030.07314.18
5.3.90.0030.03314.18
5.3.80.0030.03314.17
5.3.70.0030.04314.06
5.3.60.0070.03013.87
5.3.50.0000.03713.82
5.3.40.0100.04713.95
5.3.30.0070.05713.98
5.3.20.0030.07013.71
5.3.10.0000.07313.65
5.3.00.0030.07013.66
5.2.170.0000.06311.39
5.2.160.0000.03011.01
5.2.150.0000.03011.38
5.2.140.0130.03311.14
5.2.130.0000.06711.10
5.2.120.0070.04011.35
5.2.110.0000.04011.26
5.2.100.0070.05311.09
5.2.90.0030.03311.07
5.2.80.0030.04311.10
5.2.70.0000.06011.12
5.2.60.0030.05311.07
5.2.50.0000.04311.11
5.2.40.0000.05011.15
5.2.30.0030.02710.95
5.2.20.0100.06010.95
5.2.10.0000.06311.02
5.2.00.0000.03310.82
5.1.60.0030.02310.03
5.1.50.0070.02710.18
5.1.40.0070.03310.05
5.1.30.0170.03710.38
5.1.20.0000.06010.41
5.1.10.0030.02310.05
5.1.00.0030.05310.06
5.0.50.0000.0379.54
5.0.40.0000.0209.54
5.0.30.0000.0579.54
5.0.20.0070.0139.54
5.0.10.0000.0339.54
5.0.00.0000.0609.54
4.4.90.0000.0139.54
4.4.80.0000.0179.54
4.4.70.0000.0179.54
4.4.60.0000.0239.54
4.4.50.0030.0339.54
4.4.40.0030.0509.54
4.4.30.0030.0309.54
4.4.20.0000.0179.54
4.4.10.0030.0279.54
4.4.00.0000.0339.54
4.3.110.0000.0239.54
4.3.100.0000.0239.54
4.3.90.0000.0179.54
4.3.80.0000.0409.54
4.3.70.0000.0139.54
4.3.60.0030.0179.54
4.3.50.0000.0239.54
4.3.40.0000.0439.54
4.3.30.0030.0309.54
4.3.20.0000.0279.54
4.3.10.0030.0209.54
4.3.00.0030.0179.54

preferences:
48.28 ms | 401 KiB | 5 Q