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.70.0040.01818.56
8.3.60.0090.00616.50
8.3.50.0080.01021.96
8.3.40.0130.00318.54
8.3.30.0110.00419.04
8.3.20.0040.00420.38
8.3.10.0080.00023.48
8.3.00.0060.00319.38
8.2.180.0090.00616.63
8.2.170.0070.00722.96
8.2.160.0160.00020.38
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0070.00726.16
8.2.120.0040.00422.26
8.2.110.0040.00820.85
8.2.100.0140.00017.62
8.2.90.0040.00419.22
8.2.80.0000.00917.97
8.2.70.0000.00917.50
8.2.60.0000.00918.04
8.2.50.0090.00318.07
8.2.40.0040.00419.84
8.2.30.0000.00718.00
8.2.20.0040.00417.68
8.2.10.0070.00019.80
8.2.00.0040.00417.57
8.1.280.0070.00725.92
8.1.270.0030.00623.94
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0100.00622.14
8.1.230.0040.00718.87
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0040.00817.35
8.1.190.0000.00817.35
8.1.180.0000.00918.10
8.1.170.0030.00518.46
8.1.160.0050.00322.00
8.1.150.0040.00418.51
8.1.140.0000.00717.45
8.1.130.0080.00017.82
8.1.120.0030.00317.43
8.1.110.0050.00517.47
8.1.100.0040.00417.46
8.1.90.0030.00517.37
8.1.80.0040.00417.34
8.1.70.0070.00017.46
8.1.60.0090.00017.64
8.1.50.0000.00817.54
8.1.40.0000.00817.48
8.1.30.0000.00817.65
8.1.20.0040.00417.56
8.1.10.0000.00717.63
8.1.00.0070.00017.54
8.0.300.0000.00718.77
8.0.290.0070.00016.88
8.0.280.0000.00718.45
8.0.270.0000.00717.24
8.0.260.0040.00417.13
8.0.250.0070.00016.87
8.0.240.0040.00416.99
8.0.230.0070.00017.00
8.0.220.0040.00417.00
8.0.210.0070.00417.00
8.0.200.0060.00017.02
8.0.190.0080.00017.03
8.0.180.0030.00616.93
8.0.170.0080.00016.98
8.0.160.0000.00716.90
8.0.150.0000.00716.97
8.0.140.0050.00216.80
8.0.130.0030.00613.34
8.0.120.0060.00316.96
8.0.110.0020.00516.91
8.0.100.0040.00417.05
8.0.90.0000.00816.88
8.0.80.0070.00716.87
8.0.70.0000.00816.79
8.0.60.0040.00417.04
8.0.50.0040.00416.94
8.0.30.0090.00917.18
8.0.20.0080.01417.40
8.0.10.0040.00417.07
8.0.00.0130.00716.74
7.4.330.0050.00015.00
7.4.320.0000.00616.50
7.4.300.0000.00716.53
7.4.290.0030.00516.53
7.4.280.0030.00316.57
7.4.270.0000.00716.49
7.4.260.0030.00316.55
7.4.250.0040.00416.47
7.4.240.0050.00216.47
7.4.230.0000.00716.39
7.4.220.0080.01116.64
7.4.210.0130.00616.59
7.4.200.0000.00716.35
7.4.190.0000.00716.40
7.4.160.0120.00616.52
7.4.150.0120.00617.40
7.4.140.0120.00617.86
7.4.130.0120.00716.58
7.4.120.0100.01016.60
7.4.110.0070.01016.66
7.4.100.0060.01316.49
7.4.90.0100.00716.51
7.4.80.0210.00619.39
7.4.70.0110.00516.55
7.4.60.0140.00616.52
7.4.50.0040.00416.49
7.4.40.0060.00822.77
7.4.30.0060.00916.49
7.4.00.0050.01014.95
7.3.330.0070.00013.36
7.3.320.0000.00513.36
7.3.310.0040.00416.34
7.3.300.0050.00316.37
7.3.290.0030.01016.36
7.3.280.0050.01016.33
7.3.270.0090.00917.40
7.3.260.0110.01116.40
7.3.250.0030.01616.57
7.3.240.0170.00716.53
7.3.230.0000.01816.57
7.3.210.0100.00716.52
7.3.200.0110.01319.39
7.3.190.0120.00616.49
7.3.180.0110.00716.60
7.3.170.0030.01316.57
7.3.160.0120.00416.36
7.3.120.0050.01214.80
7.3.110.0120.00614.96
7.3.100.0060.01214.92
7.3.90.0100.01014.49
7.3.80.0000.01714.82
7.3.70.0100.01014.88
7.3.60.0030.01014.81
7.3.50.0060.00914.60
7.3.40.0070.00714.86
7.3.30.0040.00814.67
7.3.20.0100.00316.70
7.3.10.0070.00516.64
7.3.00.0060.00616.72
7.2.330.0140.00316.50
7.2.320.0120.00316.67
7.2.310.0080.01416.51
7.2.300.0100.01316.44
7.2.290.0060.01216.69
7.2.250.0080.00814.61
7.2.240.0100.01014.96
7.2.230.0040.01114.98
7.2.220.0100.01014.82
7.2.210.0140.00314.90
7.2.200.0100.00014.97
7.2.190.0070.00715.15
7.2.180.0030.01014.95
7.2.170.0090.00615.15
7.2.130.0060.00817.02
7.2.120.0090.00616.78
7.2.110.0070.00716.77
7.2.100.0040.00816.96
7.2.90.0030.01016.68
7.2.80.0030.00717.04
7.2.70.0100.00716.86
7.2.60.0060.00916.88
7.2.50.0040.01117.01
7.2.40.0030.01016.93
7.2.30.0140.00316.99
7.2.20.0110.00417.09
7.2.10.0040.01116.73
7.2.00.0070.00718.22
7.1.330.0080.00415.84
7.1.320.0080.00316.00
7.1.310.0060.00815.77
7.1.300.0040.00715.91
7.1.290.0060.00915.71
7.1.280.0090.00615.79
7.1.270.0060.00615.71
7.1.260.0040.00715.40
7.1.250.0110.00315.82
7.1.200.0000.01015.68
7.1.100.0000.01018.23
7.1.70.0000.00817.23
7.1.60.0070.01419.46
7.1.50.0100.01316.78
7.1.00.0000.08022.39
7.0.200.0030.00616.62
7.0.140.0030.07322.12
7.0.60.0200.07721.81
7.0.50.0030.04017.72
7.0.40.0000.08020.10
7.0.30.0370.04320.24
7.0.20.0300.07720.19
7.0.10.0070.06020.33
7.0.00.0000.04720.16
5.6.280.0030.07320.92
5.6.210.0000.08720.73
5.6.200.0130.05318.25
5.6.190.0200.07720.54
5.6.180.0330.06320.33
5.6.170.0270.08320.44
5.6.160.0200.07020.54
5.6.150.0070.04018.20
5.6.140.0100.07718.18
5.6.130.0100.08318.20
5.6.120.0100.07721.13
5.6.110.0100.08321.02
5.6.100.0230.06320.98
5.6.90.0030.08021.01
5.6.80.0130.06720.38
5.5.350.0270.08020.45
5.5.340.0000.06017.99
5.5.330.0130.03720.21
5.5.320.0270.04020.32
5.5.310.0300.07720.32
5.5.300.0030.08317.99
5.5.290.0000.05717.98
5.5.280.0030.08720.88
5.5.270.0100.08320.85
5.5.260.0070.08020.88
5.5.250.0000.06020.70
5.5.240.0170.07020.05
5.4.450.3930.04019.38
5.4.440.0030.07719.55
5.4.430.1430.06019.43
5.4.420.4230.04719.38
5.4.410.4670.04719.34
5.4.400.3770.03319.13
5.4.390.3900.04018.94
5.4.380.3870.03319.15
5.4.370.4000.03718.98
5.4.360.4400.04019.11
5.4.350.4200.03719.06
5.4.340.3870.04319.13
5.4.320.3300.03318.94
5.4.310.3370.03319.11
5.4.300.3000.03319.21
5.4.290.3130.03318.94
5.4.280.3000.03319.20
5.4.270.4270.05319.20
5.4.260.3700.04019.16
5.4.250.3670.03319.25
5.4.240.4200.04019.21
5.4.230.3730.04019.14
5.4.220.3800.03319.21
5.4.210.4030.03718.92
5.4.200.3800.03319.21
5.4.190.4000.04019.04
5.4.180.4070.04019.15
5.4.170.3900.03719.25
5.4.160.3900.03718.92
5.4.150.4100.03318.91
5.4.140.4070.03016.40
5.4.130.4000.03716.39
5.4.120.3770.03316.40
5.4.110.4270.03316.56
5.4.100.4130.03016.37
5.4.90.3870.03716.50
5.4.80.4400.04016.57
5.4.70.4100.03316.59
5.4.60.3470.04316.49
5.4.50.3470.03316.30
5.4.40.3870.03316.48
5.4.30.3770.04016.30
5.4.20.4030.03316.52
5.4.10.2530.03716.53
5.4.00.0070.06315.90
5.3.290.3400.03714.70
5.3.280.4100.03714.65
5.3.270.3500.03714.77
5.3.260.4000.04014.65
5.3.250.3870.04014.64
5.3.240.4300.04314.61
5.3.230.3770.04014.65
5.3.220.4130.04714.73
5.3.210.3930.03314.61
5.3.200.3970.03714.72
5.3.190.4100.03314.65
5.3.180.4170.03714.65
5.3.170.4000.03714.46
5.3.160.3670.04314.58
5.3.150.3600.04014.59
5.3.140.3770.04014.60
5.3.130.3870.03314.55
5.3.120.3800.03314.57
5.3.110.4170.04014.61
5.3.100.0100.06313.94
5.3.90.0100.07014.18
5.3.80.3700.03314.09
5.3.70.4770.03014.02
5.3.60.4400.03714.04
5.3.50.4000.02713.93
5.3.40.4170.03714.11
5.3.30.3870.03313.98
5.3.20.3770.03013.73
5.3.10.3970.03713.70
5.3.00.4030.03713.66
5.2.170.3500.02711.21
5.2.160.3470.02311.30
5.2.150.3370.03011.11
5.2.140.3430.03011.21
5.2.130.3400.03311.15
5.2.120.3500.03011.09
5.2.110.3470.02311.11
5.2.100.3200.02711.17
5.2.90.3430.03011.26
5.2.80.3200.02711.11
5.2.70.3430.02711.16
5.2.60.0070.04011.12
5.2.50.0070.05311.17
5.2.40.0030.03311.15
5.2.30.0030.03011.13
5.2.20.1670.02711.13
5.2.10.3000.03010.90
5.2.00.3300.02710.72
5.1.60.3300.0279.98
5.1.50.2970.0239.98
5.1.40.3200.02710.00
5.1.30.3330.02310.41
5.1.20.3270.03010.29
5.1.10.3000.02010.12
5.1.00.3270.02010.00
5.0.50.1800.0138.53
5.0.40.1600.0438.36
5.0.30.1670.0278.22
5.0.20.1330.0208.37
5.0.10.1430.0208.18
5.0.00.1300.0308.13
4.4.90.1300.0175.84
4.4.80.0000.0205.77
4.4.70.1530.0175.88
4.4.60.1630.0105.92
4.4.50.1670.0175.77
4.4.40.1730.0275.88
4.4.30.1770.0175.81
4.4.20.1530.0175.86
4.4.10.1170.0175.99
4.4.00.1870.0275.87
4.3.110.1500.0175.79
4.3.100.1430.0175.73
4.3.90.1430.0235.67
4.3.80.0770.0505.71
4.3.70.1370.0135.78
4.3.60.1570.0205.77
4.3.50.1430.0175.78
4.3.40.1530.0275.68
4.3.30.0870.0174.61
4.3.20.0870.0204.61
4.3.10.0500.0174.61
4.3.00.0830.0234.61

preferences:
58.63 ms | 401 KiB | 5 Q