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 $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.0130.00718.43
8.3.50.0110.00521.97
8.3.40.0140.00718.71
8.3.30.0090.00619.21
8.3.20.0000.00820.30
8.3.10.0080.00022.09
8.3.00.0030.00522.31
8.2.180.0120.00616.75
8.2.170.0110.00422.96
8.2.160.0030.01020.52
8.2.150.0000.00924.18
8.2.140.0030.00624.66
8.2.130.0030.00526.16
8.2.120.0050.00319.22
8.2.110.0070.00320.99
8.2.100.0110.00018.09
8.2.90.0050.00319.18
8.2.80.0030.00617.97
8.2.70.0060.00317.63
8.2.60.0040.00417.80
8.2.50.0040.00418.10
8.2.40.0050.00220.41
8.2.30.0020.00519.30
8.2.20.0000.00817.71
8.2.10.0000.00819.34
8.2.00.0040.00417.57
8.1.280.0140.00725.92
8.1.270.0080.00022.11
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00623.80
8.1.230.0110.00020.45
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0060.00617.23
8.1.190.0000.00817.35
8.1.180.0000.00818.10
8.1.170.0080.00018.64
8.1.160.0000.00718.89
8.1.150.0000.00720.02
8.1.140.0000.00717.49
8.1.130.0080.00017.84
8.1.120.0000.00717.43
8.1.110.0000.00817.43
8.1.100.0040.00417.51
8.1.90.0050.00317.43
8.1.80.0000.00717.41
8.1.70.0040.00417.31
8.1.60.0000.00717.48
8.1.50.0030.00617.53
8.1.40.0030.00617.40
8.1.30.0050.00317.64
8.1.20.0080.00017.68
8.1.10.0040.00417.41
8.1.00.0000.00817.55
8.0.300.0000.00818.77
8.0.290.0030.00616.75
8.0.280.0000.00818.46
8.0.270.0040.00317.25
8.0.260.0000.00716.77
8.0.250.0070.00016.92
8.0.240.0040.00417.05
8.0.230.0080.00016.86
8.0.220.0000.00716.93
8.0.210.0030.00516.85
8.0.200.0040.00217.03
8.0.190.0040.00317.05
8.0.180.0050.00317.02
8.0.170.0060.00316.98
8.0.160.0040.00416.82
8.0.150.0060.00316.88
8.0.140.0050.00316.84
8.0.130.0050.00013.32
8.0.120.0000.00816.95
8.0.110.0000.00816.99
8.0.100.0050.00216.98
8.0.90.0000.00716.95
8.0.80.0030.01116.93
8.0.70.0070.00016.74
8.0.60.0030.00416.95
8.0.50.0040.00417.02
8.0.30.0100.01016.96
8.0.20.0150.00317.41
8.0.10.0040.00417.07
8.0.00.0080.01416.85
7.4.330.0000.00615.00
7.4.320.0060.00016.52
7.4.300.0030.00316.48
7.4.290.0000.00716.61
7.4.280.0030.00516.50
7.4.270.0030.00316.64
7.4.260.0070.00016.58
7.4.250.0000.00816.55
7.4.240.0050.00216.51
7.4.230.0030.00316.58
7.4.220.0040.01416.68
7.4.210.0100.00416.61
7.4.200.0030.00316.44
7.4.190.0000.00716.68
7.4.160.0060.01316.49
7.4.150.0000.01617.40
7.4.140.0100.00917.86
7.4.130.0080.01116.53
7.4.120.0140.00416.51
7.4.110.0070.01016.45
7.4.100.0110.01016.52
7.4.90.0070.01016.59
7.4.80.0030.01619.39
7.4.70.0070.01016.43
7.4.60.0150.00916.48
7.4.50.0040.00416.72
7.4.40.0070.00722.77
7.4.30.0110.00516.64
7.4.00.0070.01014.98
7.3.330.0030.00313.32
7.3.320.0000.00513.34
7.3.310.0070.00016.23
7.3.300.0030.00316.32
7.3.290.0090.00616.30
7.3.280.0080.00916.33
7.3.270.0100.00717.40
7.3.260.0130.00716.37
7.3.250.0040.01416.54
7.3.240.0140.00716.26
7.3.230.0060.01516.39
7.3.210.0160.00016.66
7.3.200.0060.01019.39
7.3.190.0100.00716.43
7.3.180.0040.01216.41
7.3.170.0060.00916.29
7.3.160.0090.01216.44
7.3.120.0030.00715.01
7.2.330.0060.01216.52
7.2.320.0030.01216.77
7.2.310.0120.00616.67
7.2.300.0060.01016.75
7.2.290.0070.01016.73
7.2.60.0110.00417.07
7.2.00.0030.01319.18
7.1.200.0030.00915.90
7.1.100.0030.00917.95
7.1.70.0000.01017.01
7.1.60.0070.01819.82
7.1.50.0070.01316.76
7.1.00.0100.07022.30
7.0.200.0000.00716.71
7.0.140.0100.06722.10
7.0.60.0030.08319.93
7.0.50.0070.06017.86
7.0.40.0130.08320.23
7.0.30.0300.06320.10
7.0.20.0370.07320.23
7.0.10.0300.04720.08
7.0.00.0100.06320.09
5.6.280.0000.07721.13
5.6.210.0200.07020.74
5.6.200.0070.08018.24
5.6.190.0070.07720.47
5.6.180.4200.04320.58
5.6.170.0230.05720.61
5.6.160.0100.07320.50
5.6.150.0100.06318.23
5.6.140.0100.07318.18
5.6.130.0030.04018.28
5.6.120.0100.08021.02
5.6.110.0030.06021.12
5.6.100.0130.06721.00
5.6.90.0130.07720.98
5.6.80.0100.07320.52
5.5.350.0100.07720.53
5.5.340.0130.04017.95
5.5.330.0170.06720.43
5.5.320.0230.08320.24
5.5.310.0430.06720.32
5.5.300.0070.06717.95
5.5.290.0030.04017.99
5.5.280.0000.04720.79
5.5.270.0200.07020.68
5.5.260.0130.07720.96
5.5.250.0130.08020.80
5.5.240.0070.05720.13
5.4.450.0670.05719.59
5.4.440.0670.05319.47
5.4.430.0200.04719.55
5.4.420.0070.06019.68
5.4.410.0100.05319.35
5.4.400.0870.00018.82
5.4.390.0830.00018.75
5.4.380.0200.05718.73
5.4.370.0200.05318.84
5.4.360.0230.05018.63
5.4.350.0170.06018.78
5.4.340.0200.05718.79
5.4.320.0060.03612.50
5.4.310.0130.04812.50
5.4.300.0040.03812.51
5.4.290.0060.03912.50
5.4.280.0050.03612.40
5.4.270.0070.04312.40
5.4.260.0170.06718.77
5.4.250.0000.06318.98
5.4.240.0030.06018.75
5.4.230.0100.06018.75
5.4.220.0070.06018.86
5.4.210.0130.05018.80
5.4.200.0030.08018.95
5.4.190.0070.07018.92
5.4.180.0030.05718.91
5.4.170.0100.05718.92
5.4.160.0030.05718.71
5.4.150.0130.06718.92
5.4.140.0100.05316.55
5.4.130.0100.04716.39
5.4.120.0170.04316.43
5.4.110.0130.06716.43
5.4.100.0170.04016.38
5.4.90.0100.05016.50
5.4.80.0200.05716.37
5.4.70.0070.05316.37
5.4.60.0130.06016.56
5.4.50.0030.05716.37
5.4.40.0200.04316.42
5.4.30.0100.05716.42
5.4.20.0000.05716.27
5.4.10.0130.04716.55
5.4.00.0270.05315.99
5.3.290.0070.03812.80
5.3.280.0100.04714.44
5.3.270.0070.05314.46
5.3.260.0130.06714.68
5.3.250.0100.07014.70
5.3.240.0100.05014.75
5.3.230.0070.05714.77
5.3.220.0200.04014.55
5.3.210.0030.06014.55
5.3.200.0130.05714.41
5.3.190.0130.05714.59
5.3.180.0070.07014.40
5.3.170.0070.07014.80
5.3.160.0100.07014.48
5.3.150.0270.04714.41
5.3.140.0130.04314.65
5.3.130.0170.05314.53
5.3.120.0130.04714.64
5.3.110.0130.05314.64
5.3.100.0070.05314.22
5.3.90.0000.07314.00
5.3.80.0070.05314.10
5.3.70.0100.04714.04
5.3.60.0100.05714.02
5.3.50.0030.05014.05
5.3.40.0130.04314.12
5.3.30.0070.08014.00
5.3.20.0200.03713.78
5.3.10.0070.04713.74
5.3.00.0030.05313.48
5.2.170.0070.04711.22
5.2.160.0030.05011.14
5.2.150.0000.04711.16
5.2.140.0130.03311.22
5.2.130.0030.04311.11
5.2.120.0070.04711.33
5.2.110.0100.05311.09
5.2.100.0030.04011.17
5.2.90.0100.05311.27
5.2.80.0100.03711.17
5.2.70.0170.03311.10
5.2.60.0070.06011.13
5.2.50.0100.05010.94
5.2.40.0030.04710.91
5.2.30.0070.04710.88
5.2.20.0130.05010.80
5.2.10.0100.04710.70
5.2.00.0000.04310.82
5.1.60.0170.03310.20
5.1.50.0130.02710.07
5.1.40.0100.03710.21
5.1.30.0030.04010.41
5.1.20.0030.03710.45
5.1.10.0070.03310.15
5.1.00.0070.0379.91
5.0.50.0030.0308.71
5.0.40.0100.0278.40
5.0.30.0070.0408.33
5.0.20.0070.0308.22
5.0.10.0070.0238.26
5.0.00.0070.0508.25
4.4.90.0000.0236.96
4.4.80.0030.0206.96
4.4.70.0000.0306.96
4.4.60.0000.0276.96
4.4.50.0030.0306.96
4.4.40.0000.0406.96
4.4.30.0100.0176.96
4.4.20.0000.0336.96
4.4.10.0000.0236.96
4.4.00.0070.0306.96
4.3.110.0030.0206.96
4.3.100.0070.0176.96
4.3.90.0030.0276.96
4.3.80.0030.0436.96
4.3.70.0030.0276.96
4.3.60.0070.0176.96
4.3.50.0070.0176.96
4.3.40.0070.0306.96
4.3.30.0070.0236.96
4.3.20.0000.0336.96
4.3.10.0030.0206.96
4.3.00.0130.0277.46

preferences:
50.92 ms | 401 KiB | 5 Q