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.00718.34
8.3.50.0110.01222.04
8.3.40.0160.00318.79
8.3.30.0120.00619.24
8.3.20.0040.00420.34
8.3.10.0080.00021.92
8.3.00.0120.00622.43
8.2.180.0130.00616.36
8.2.170.0140.00722.96
8.2.160.0150.00020.94
8.2.150.0070.00724.18
8.2.140.0150.00424.66
8.2.130.0080.00026.16
8.2.120.0060.00319.23
8.2.110.0030.00621.10
8.2.100.0040.00817.79
8.2.90.0000.00817.84
8.2.80.0050.00317.97
8.2.70.0060.00317.63
8.2.60.0000.00817.80
8.2.50.0000.00818.07
8.2.40.0080.00018.09
8.2.30.0070.00018.00
8.2.20.0050.00217.66
8.2.10.0050.00319.48
8.2.00.0030.00617.69
8.1.280.0120.00625.92
8.1.270.0030.00623.82
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00622.18
8.1.230.0070.00420.89
8.1.220.0060.00317.74
8.1.210.0000.00920.20
8.1.200.0000.00817.35
8.1.190.0030.00617.52
8.1.180.0080.00018.56
8.1.170.0030.00618.63
8.1.160.0000.00722.00
8.1.150.0040.00418.63
8.1.140.0040.00417.44
8.1.130.0070.00017.82
8.1.120.0000.00817.48
8.1.110.0040.00417.45
8.1.100.0000.00717.42
8.1.90.0000.00717.51
8.1.80.0040.00417.47
8.1.70.0030.00317.38
8.1.60.0000.00917.62
8.1.50.0000.00817.40
8.1.40.0000.00717.52
8.1.30.0040.00417.46
8.1.20.0040.00417.71
8.1.10.0000.00717.59
8.1.00.0050.00217.52
8.0.300.0030.00320.07
8.0.290.0020.00516.75
8.0.280.0040.00418.45
8.0.270.0040.00417.18
8.0.260.0000.00716.79
8.0.250.0030.00316.91
8.0.240.0000.00717.00
8.0.230.0000.00716.89
8.0.220.0000.00716.79
8.0.210.0000.00716.79
8.0.200.0070.00016.90
8.0.190.0030.00616.97
8.0.180.0000.00716.98
8.0.170.0000.00717.00
8.0.160.0040.00416.95
8.0.150.0070.00016.83
8.0.140.0070.00016.93
8.0.130.0060.00013.43
8.0.120.0030.00516.93
8.0.110.0070.00016.98
8.0.100.0080.00016.82
8.0.90.0080.00016.98
8.0.80.0060.00917.00
8.0.70.0050.00317.02
8.0.60.0000.00716.99
8.0.50.0070.00016.77
8.0.30.0100.00917.06
8.0.20.0060.01517.40
8.0.10.0050.00317.01
8.0.00.0070.01116.84
7.4.330.0030.00315.15
7.4.320.0000.00716.46
7.4.300.0060.00016.51
7.4.290.0030.00316.51
7.4.280.0000.00716.50
7.4.270.0030.00316.59
7.4.260.0030.00316.52
7.4.250.0000.00716.56
7.4.240.0020.00616.46
7.4.230.0030.00316.30
7.4.220.0070.01716.42
7.4.210.0090.00816.54
7.4.200.0000.00716.54
7.4.190.0030.00316.50
7.4.160.0130.00316.41
7.4.150.0040.01417.40
7.4.140.0100.00717.86
7.4.130.0080.01116.59
7.4.120.0090.01116.53
7.4.110.0140.00316.61
7.4.100.0150.00316.66
7.4.90.0190.00016.57
7.4.80.0120.00619.39
7.4.70.0130.00316.42
7.4.60.0120.00616.58
7.4.50.0000.00516.61
7.4.40.0030.01022.77
7.4.30.0090.01216.64
7.4.00.0070.00714.89
7.3.330.0000.00513.39
7.3.320.0030.00213.43
7.3.310.0040.00416.26
7.3.300.0000.00816.25
7.3.290.0070.00716.38
7.3.280.0100.00716.33
7.3.270.0130.00717.40
7.3.260.0090.00916.32
7.3.250.0120.01016.48
7.3.240.0150.00316.52
7.3.230.0160.00816.39
7.3.210.0030.01316.32
7.3.200.0060.01019.39
7.3.190.0090.01216.49
7.3.180.0040.01216.23
7.3.170.0090.01316.49
7.3.160.0090.00916.50
7.3.120.0000.01414.90
7.2.330.0070.01016.50
7.2.320.0090.01216.63
7.2.310.0110.01316.59
7.2.300.0100.00716.58
7.2.290.0140.00316.56
7.2.60.0030.01017.02
7.2.00.0000.01219.42
7.1.200.0090.00315.67
7.1.100.0060.00618.23
7.1.70.0050.00316.93
7.1.60.0150.00919.82
7.1.50.0090.00916.86
7.1.00.0070.07322.36
7.0.200.0040.00416.57
7.0.140.0000.08022.15
7.0.60.0100.07319.92
7.0.50.0100.08717.88
7.0.40.0130.08320.23
7.0.30.0370.07020.26
7.0.20.0230.05020.25
7.0.10.0400.06720.23
7.0.00.0030.04320.29
5.6.280.0070.07021.05
5.6.210.0070.05720.76
5.6.200.0100.05718.13
5.6.190.0100.06720.46
5.6.180.0030.04320.66
5.6.170.0300.07320.63
5.6.160.0030.08720.54
5.6.150.0170.07018.15
5.6.140.0030.08718.25
5.6.130.0170.04718.23
5.6.120.0170.07020.99
5.6.110.0170.07721.01
5.6.100.0100.08020.98
5.6.90.0070.08320.98
5.6.80.0070.07020.39
5.6.70.0270.07020.40
5.5.350.0030.07720.45
5.5.340.0070.09018.02
5.5.330.0030.08720.27
5.5.320.0170.04320.24
5.5.310.0170.04320.34
5.5.300.0100.07717.94
5.5.290.0030.06717.98
5.5.280.0100.04020.88
5.5.270.0070.07320.77
5.5.260.0070.06720.77
5.5.250.0230.06020.58
5.5.240.0170.06720.36
5.4.450.0530.05719.55
5.4.440.0370.06319.70
5.4.430.0270.05019.55
5.4.420.0400.04019.62
5.4.410.0200.04318.70
5.4.400.1870.00018.82
5.4.390.1900.00018.54
5.4.380.0300.04718.77
5.4.370.0170.05718.70
5.4.360.0270.04318.84
5.4.350.0270.05018.63
5.4.340.0370.05018.71
5.4.320.0060.04012.51
5.4.310.0060.03912.50
5.4.300.0060.03712.50
5.4.290.0080.03912.50
5.4.280.0080.04012.40
5.4.270.0080.03412.40
5.4.260.0030.06018.90
5.4.250.0170.04318.99
5.4.240.0070.05318.95
5.4.230.0130.06318.80
5.4.220.0070.07318.90
5.4.210.0000.06718.77
5.4.200.0130.04718.80
5.4.190.0100.05318.91
5.4.180.0000.06718.72
5.4.170.0030.05718.95
5.4.160.0100.04718.92
5.4.150.0070.05318.95
5.4.140.0100.05716.45
5.4.130.0130.07016.41
5.4.120.0030.05316.47
5.4.110.0200.03716.40
5.4.100.0130.04316.35
5.4.90.0070.04716.49
5.4.80.0170.03716.52
5.4.70.0030.05316.38
5.4.60.0030.05716.44
5.4.50.0070.04716.35
5.4.40.0000.05316.40
5.4.30.0070.05016.58
5.4.20.0130.04316.49
5.4.10.0170.05316.34
5.4.00.0070.04715.93
5.3.290.0070.04112.80
5.3.280.0100.07314.57
5.3.270.0070.05014.84
5.3.260.0070.05014.68
5.3.250.0030.07714.70
5.3.240.0130.04314.60
5.3.230.0130.06314.69
5.3.220.0070.06014.41
5.3.210.0070.05314.64
5.3.200.0230.06014.65
5.3.190.0130.04314.76
5.3.180.0030.05314.59
5.3.170.0230.03314.56
5.3.160.0070.07314.56
5.3.150.0070.05014.54
5.3.140.0100.04714.65
5.3.130.0130.04314.65
5.3.120.0130.05314.46
5.3.110.0130.05314.64
5.3.100.0100.04314.09
5.3.90.0100.04714.10
5.3.80.0000.05314.11
5.3.70.0100.06713.99
5.3.60.0130.04314.16
5.3.50.0100.05714.02
5.3.40.0030.05313.94
5.3.30.0100.05314.00
5.3.20.0070.06313.77
5.3.10.0100.04313.64
5.3.00.0100.04313.64
5.2.170.0030.04311.23
5.2.160.0030.04011.21
5.2.150.0000.04711.05
5.2.140.0130.04011.23
5.2.130.0100.03711.07
5.2.120.0100.03311.18
5.2.110.0070.03711.18
5.2.100.0030.04011.09
5.2.90.0100.05711.02
5.2.80.0030.04310.93
5.2.70.0100.03711.28
5.2.60.0000.04311.14
5.2.50.0030.05311.04
5.2.40.0030.04311.07
5.2.30.0030.04711.07
5.2.20.0000.04311.04
5.2.10.0100.03310.70
5.2.00.0070.04010.82
5.1.60.0070.0309.84
5.1.50.0100.03010.16
5.1.40.0030.0379.95
5.1.30.0030.03310.32
5.1.20.0070.05010.27
5.1.10.0000.03710.04
5.1.00.0070.03710.12
5.0.50.0030.0278.52
5.0.40.0070.0238.58
5.0.30.0030.0508.16
5.0.20.0070.0278.04
5.0.10.0000.0308.28
5.0.00.0030.0408.26
4.4.90.0030.0207.01
4.4.80.0000.0237.01
4.4.70.0000.0307.01
4.4.60.0000.0237.01
4.4.50.0000.0337.01
4.4.40.0070.0437.01
4.4.30.0030.0207.01
4.4.20.0030.0207.01
4.4.10.0000.0237.01
4.4.00.0000.0437.01
4.3.110.0070.0177.01
4.3.100.0030.0207.01
4.3.90.0000.0237.01
4.3.80.0000.0337.01
4.3.70.0000.0237.01
4.3.60.0030.0277.01
4.3.50.0000.0307.01
4.3.40.0000.0337.01
4.3.30.0000.0277.01
4.3.20.0030.0207.01
4.3.10.0100.0137.01
4.3.00.0030.0207.17

preferences:
41.13 ms | 401 KiB | 5 Q