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 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.01018.43
8.3.50.0080.00821.14
8.3.40.0070.00718.63
8.3.30.0140.00020.38
8.3.20.0000.00920.30
8.3.10.0000.00822.10
8.3.00.0000.00822.35
8.2.180.0120.00616.38
8.2.170.0110.00322.96
8.2.160.0000.01422.08
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0090.00626.16
8.2.120.0030.01719.66
8.2.110.0070.01022.26
8.2.100.0030.00917.78
8.2.90.0000.00819.22
8.2.80.0040.00419.11
8.2.70.0090.00017.50
8.2.60.0040.00419.77
8.2.50.0000.00818.07
8.2.40.0000.00818.07
8.2.30.0000.00818.04
8.2.20.0060.00317.57
8.2.10.0040.00417.67
8.2.00.0030.00717.74
8.1.280.0090.00925.92
8.1.270.0080.00024.66
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0130.00323.89
8.1.230.0040.00818.92
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0080.00417.13
8.1.190.0000.00817.51
8.1.180.0000.00919.01
8.1.170.0000.00918.48
8.1.160.0080.00022.13
8.1.150.0040.00418.63
8.1.140.0040.00417.38
8.1.130.0000.00817.81
8.1.120.0040.00417.44
8.1.110.0080.00017.42
8.1.100.0040.00417.38
8.1.90.0000.00717.45
8.1.80.0000.00717.41
8.1.70.0000.00717.39
8.1.60.0000.00917.57
8.1.50.0070.00317.46
8.1.40.0000.00817.41
8.1.30.0040.00417.64
8.1.20.0060.00317.66
8.1.10.0070.00017.48
8.1.00.0040.00417.54
8.0.300.0060.00319.21
8.0.290.0040.00417.18
8.0.280.0100.00318.45
8.0.270.0030.00317.13
8.0.260.0000.00616.89
8.0.250.0070.00016.92
8.0.240.0080.00016.92
8.0.230.0040.00416.98
8.0.220.0070.00016.98
8.0.210.0040.00416.90
8.0.200.0000.00616.95
8.0.190.0000.01016.91
8.0.180.0040.00417.05
8.0.170.0040.00416.86
8.0.160.0070.00016.78
8.0.150.0000.00716.79
8.0.140.0040.00416.88
8.0.130.0030.00313.36
8.0.120.0000.00816.81
8.0.110.0070.00016.93
8.0.100.0030.00616.82
8.0.90.0040.00417.04
8.0.80.0090.01016.98
8.0.70.0040.00416.98
8.0.60.0000.00916.83
8.0.50.0020.00517.07
8.0.30.0100.01216.90
8.0.20.0090.00917.40
8.0.10.0070.00017.02
8.0.00.0060.01416.90
7.4.330.0000.00615.00
7.4.320.0000.00616.52
7.4.300.0060.00016.45
7.4.290.0000.00716.61
7.4.280.0000.00716.55
7.4.270.0040.00416.42
7.4.260.0030.00616.52
7.4.250.0030.00516.32
7.4.240.0020.00516.53
7.4.230.0030.00316.53
7.4.220.0030.02216.47
7.4.210.0080.00816.55
7.4.200.0040.00416.40
7.4.190.0070.00016.58
7.4.160.0110.01116.55
7.4.150.0090.00917.40
7.4.140.0120.00617.86
7.4.130.0150.00216.63
7.4.120.0100.00716.72
7.4.110.0090.01516.51
7.4.100.0150.00616.46
7.4.90.0090.00916.68
7.4.80.0120.00619.39
7.4.70.0080.00916.43
7.4.60.0100.00716.45
7.4.50.0030.00616.38
7.4.40.0090.00922.77
7.4.30.0060.01016.52
7.4.00.0040.01214.99
7.3.330.0050.00013.32
7.3.320.0030.00213.22
7.3.310.0000.00716.38
7.3.300.0060.00016.20
7.3.290.0100.00316.33
7.3.280.0070.00916.32
7.3.270.0100.00717.40
7.3.260.0030.01716.37
7.3.250.0080.00816.43
7.3.240.0100.00616.34
7.3.230.0110.00716.57
7.3.210.0080.00816.56
7.3.200.0040.01219.39
7.3.190.0040.01716.30
7.3.180.0130.00316.34
7.3.170.0120.00316.59
7.3.160.0030.01316.50
7.3.120.0030.01014.69
7.3.110.0040.00714.93
7.3.100.0090.00615.03
7.3.90.0060.01014.82
7.3.80.0070.00714.98
7.3.70.0030.00914.83
7.3.60.0090.00614.64
7.3.50.0070.00614.92
7.3.40.0100.00314.64
7.3.30.0030.00914.60
7.3.20.0080.00416.74
7.3.10.0060.00616.72
7.3.00.0050.01016.74
7.2.330.0100.01016.38
7.2.320.0080.01316.39
7.2.310.0130.00616.72
7.2.300.0060.01216.78
7.2.290.0100.00716.35
7.2.250.0000.01914.99
7.2.240.0130.00315.07
7.2.230.0090.00614.98
7.2.220.0100.00315.20
7.2.210.0030.01314.79
7.2.200.0030.01014.93
7.2.190.0000.01614.81
7.2.180.0060.01215.04
7.2.170.0070.00314.87
7.2.130.0070.00716.92
7.2.120.0080.00816.86
7.2.110.0070.00316.88
7.2.100.0070.00716.90
7.2.90.0060.00917.12
7.2.80.0040.00816.79
7.2.70.0030.01016.98
7.2.60.0070.01016.79
7.2.50.0000.01316.87
7.2.40.0100.00716.77
7.2.30.0040.00817.06
7.2.20.0090.00317.06
7.2.10.0060.00616.88
7.2.00.0060.00618.16
7.1.330.0090.00615.76
7.1.320.0110.00415.87
7.1.310.0060.00615.59
7.1.300.0080.00415.44
7.1.290.0120.00615.84
7.1.280.0030.00615.78
7.1.270.0000.00815.46
7.1.260.0000.01115.68
7.1.250.0050.00315.56
7.1.200.0070.00315.82
7.1.100.0060.00818.19
7.1.70.0000.00817.17
7.1.60.0100.01419.43
7.1.50.0060.01616.86
7.1.00.0000.07322.40
7.0.200.0070.00316.84
7.0.140.0070.06722.02
7.0.60.0030.05019.93
7.0.50.0130.06017.84
7.0.40.0030.04320.30
7.0.30.0270.04320.38
7.0.20.0200.08320.22
7.0.10.0330.07320.13
7.0.00.0000.08320.32
5.6.280.0000.07721.09
5.6.210.0030.08320.56
5.6.200.0030.06718.15
5.6.190.0200.07320.56
5.6.180.0200.03720.45
5.6.170.0470.07020.53
5.6.160.0100.07720.47
5.6.150.0170.07018.29
5.6.140.0030.07318.25
5.6.130.0100.07718.15
5.6.120.0070.07020.98
5.6.110.0170.07721.02
5.6.100.0070.08020.98
5.6.90.0070.06020.96
5.6.80.0030.08320.43
5.6.70.0200.04020.38
5.5.350.0170.04020.44
5.5.340.0030.08718.07
5.5.330.0170.07020.13
5.5.320.0330.06720.27
5.5.310.0270.07720.30
5.5.300.0130.04318.04
5.5.290.0030.04017.96
5.5.280.0070.04020.88
5.5.270.0030.08320.80
5.5.260.0000.04720.69
5.5.250.0070.06320.71
5.5.240.0130.07320.16
5.4.450.0630.05719.63
5.4.440.0430.07719.38
5.4.430.0870.04319.43
5.4.420.0730.05719.47
5.4.410.1000.06019.56
5.4.400.0330.05018.77
5.4.390.0500.06718.79
5.4.380.0300.04718.50
5.4.370.0230.04718.75
5.4.360.0170.05318.78
5.4.350.0080.03312.03
5.4.340.0060.03612.03
5.4.320.0100.03212.51
5.4.310.0050.03912.50
5.4.300.0040.03812.50
5.4.290.0080.03712.51
5.4.280.0060.03612.40
5.4.270.0060.04312.41
5.4.260.0060.03712.40
5.4.250.0070.05318.77
5.4.240.0070.05718.98
5.4.230.0100.05019.02
5.4.220.0100.07318.76
5.4.210.0070.08018.97
5.4.200.0070.05018.79
5.4.190.0170.04018.76
5.4.180.0030.05318.96
5.4.170.0130.04318.84
5.4.160.0130.04318.75
5.4.150.0100.05018.96
5.4.140.0170.04316.45
5.4.130.0100.04316.39
5.4.120.0070.05716.63
5.4.110.0030.06716.57
5.4.100.0070.05016.54
5.4.90.0130.05316.63
5.4.80.0070.06016.52
5.4.70.0100.05016.69
5.4.60.0100.04316.45
5.4.50.0070.04716.55
5.4.40.0130.04316.36
5.4.30.0170.04316.59
5.4.20.0070.04716.44
5.4.10.0000.05716.41
5.4.00.0070.04715.79
5.3.290.0040.05112.80
5.3.280.0070.06314.83
5.3.270.0030.05314.84
5.3.260.0100.04714.67
5.3.250.0070.05014.75
5.3.240.0130.06314.68
5.3.230.0100.04714.59
5.3.220.0030.05014.65
5.3.210.0070.05014.65
5.3.200.0170.05714.66
5.3.190.0030.05314.73
5.3.180.0100.05014.66
5.3.170.0070.06014.74
5.3.160.0130.05014.56
5.3.150.0070.05014.59
5.3.140.0100.04314.47
5.3.130.0170.04714.58
5.3.120.0130.04714.63
5.3.110.0100.05014.74
5.3.100.0070.04714.11
5.3.90.0030.05314.09
5.3.80.0100.06714.00
5.3.70.0070.05314.04
5.3.60.0130.04014.02
5.3.50.0100.04713.96
5.3.40.0070.05013.93
5.3.30.0100.05013.75
5.3.20.0100.04713.72
5.3.10.0100.04313.74
5.3.00.0200.04713.73
5.2.170.0030.04311.31
5.2.160.0030.04011.14
5.2.150.0000.04711.37
5.2.140.0070.04011.30
5.2.130.0100.03711.07
5.2.120.0070.04011.01
5.2.110.0000.06011.06
5.2.100.0030.05011.17
5.2.90.0070.03711.29
5.2.80.0100.03311.16
5.2.70.0100.03711.32
5.2.60.0100.05311.24
5.2.50.0030.04311.11
5.2.40.0030.04011.23
5.2.30.0100.03711.06
5.2.20.0000.04310.97
5.2.10.0030.03711.05
5.2.00.0230.03710.92
5.1.60.0030.03310.04
5.1.50.0100.02710.04
5.1.40.0070.03010.09
5.1.30.0100.03010.41
5.1.20.0030.03710.54
5.1.10.0000.0379.91
5.1.00.0130.02710.27
5.0.50.0070.0308.71
5.0.40.0030.0278.49
5.0.30.0030.0408.07
5.0.20.0000.0308.25
5.0.10.0070.0238.16
5.0.00.0000.0438.16
4.4.90.0070.0177.27
4.4.80.0030.0207.27
4.4.70.0030.0207.27
4.4.60.0030.0307.27
4.4.50.0030.0207.27
4.4.40.0070.0307.27
4.4.30.0030.0207.27
4.4.20.0070.0177.27
4.4.10.0030.0207.27
4.4.00.0000.0377.27
4.3.110.0000.0237.27
4.3.100.0070.0177.27
4.3.90.0100.0207.27
4.3.80.0000.0337.27
4.3.70.0000.0237.27
4.3.60.0000.0207.27
4.3.50.0000.0277.27
4.3.40.0070.0277.27
4.3.30.0030.0237.27
4.3.20.0030.0207.27
4.3.10.0000.0237.27
4.3.00.0070.0237.63

preferences:
36.68 ms | 401 KiB | 5 Q