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 2 + 2; } } // 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.30
8.3.50.0130.00821.96
8.3.40.0120.00318.84
8.3.30.0080.00619.17
8.3.20.0070.00020.34
8.3.10.0040.00421.95
8.3.00.0080.00022.36
8.2.180.0150.00316.50
8.2.170.0070.00722.96
8.2.160.0100.00320.82
8.2.150.0070.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00017.63
8.2.110.0060.00319.27
8.2.100.0070.00317.84
8.2.90.0040.00419.17
8.2.80.0050.00317.97
8.2.70.0090.00017.63
8.2.60.0060.00317.93
8.2.50.0000.00818.07
8.2.40.0040.00418.22
8.2.30.0000.00718.12
8.2.20.0000.00817.73
8.2.10.0030.00617.63
8.2.00.0000.00717.84
8.1.280.0100.01025.92
8.1.270.0080.00022.02
8.1.260.0050.00226.35
8.1.250.0030.00528.09
8.1.240.0050.00522.62
8.1.230.0110.00418.72
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0030.00717.38
8.1.190.0030.00617.55
8.1.180.0060.00318.10
8.1.170.0040.00418.57
8.1.160.0050.00322.07
8.1.150.0000.00818.64
8.1.140.0040.00417.50
8.1.130.0050.00317.84
8.1.120.0030.00517.38
8.1.110.0070.00317.48
8.1.100.0080.00017.44
8.1.90.0000.00717.33
8.1.80.0000.00717.49
8.1.70.0000.00717.45
8.1.60.0050.00317.55
8.1.50.0040.00417.39
8.1.40.0000.00817.52
8.1.30.0040.00417.64
8.1.20.0060.00317.71
8.1.10.0060.00317.48
8.1.00.0050.00317.42
8.0.300.0000.00718.77
8.0.290.0040.00417.18
8.0.280.0000.00718.34
8.0.270.0000.00717.36
8.0.260.0030.00316.88
8.0.250.0030.00617.02
8.0.240.0040.00417.01
8.0.230.0050.00317.08
8.0.220.0000.00716.96
8.0.210.0030.00316.87
8.0.200.0000.00717.04
8.0.190.0000.00717.02
8.0.180.0000.00716.87
8.0.170.0030.00516.88
8.0.160.0050.00216.95
8.0.150.0000.00916.89
8.0.140.0050.00316.82
8.0.130.0060.00013.37
8.0.120.0000.00816.83
8.0.110.0030.00316.89
8.0.100.0000.00716.91
8.0.90.0000.00716.96
8.0.80.0040.01117.00
8.0.70.0070.00016.83
8.0.60.0080.00016.77
8.0.50.0000.00716.84
8.0.30.0100.00817.14
8.0.20.0150.00317.40
8.0.10.0040.00416.94
8.0.00.0090.00916.65
7.4.330.0050.00015.15
7.4.320.0000.00616.48
7.4.300.0000.00616.52
7.4.290.0000.00716.65
7.4.280.0030.00316.57
7.4.270.0000.00716.66
7.4.260.0000.00716.40
7.4.250.0000.00816.47
7.4.240.0040.00316.56
7.4.230.0030.00316.69
7.4.220.0120.00916.50
7.4.210.0090.00716.59
7.4.200.0000.00716.45
7.4.190.0040.00416.52
7.4.160.0100.01016.58
7.4.150.0100.00717.40
7.4.140.0080.01017.86
7.4.130.0110.01016.54
7.4.120.0100.01016.62
7.4.110.0100.00716.51
7.4.100.0070.01016.73
7.4.90.0120.00616.50
7.4.80.0100.01019.39
7.4.70.0080.00816.59
7.4.60.0080.00916.45
7.4.50.0000.00516.79
7.4.40.0030.01222.77
7.4.30.0040.01816.64
7.4.00.0070.00715.21
7.3.330.0030.00313.23
7.3.320.0030.00313.17
7.3.310.0030.00316.34
7.3.300.0000.00716.36
7.3.290.0050.01016.36
7.3.280.0050.01416.38
7.3.270.0040.01317.40
7.3.260.0090.00916.70
7.3.250.0110.00616.55
7.3.240.0070.01016.42
7.3.230.0060.01216.41
7.3.210.0140.00316.67
7.3.200.0140.00319.39
7.3.190.0100.01016.56
7.3.180.0100.00716.50
7.3.170.0090.00616.55
7.3.160.0060.01016.49
7.3.120.0040.01214.64
7.2.330.0110.00716.41
7.2.320.0100.00716.68
7.2.310.0150.00916.85
7.2.300.0060.01016.33
7.2.290.0030.01416.43
7.2.60.0060.00916.90
7.2.50.0030.01316.91
7.2.00.0030.01219.33
7.1.200.0070.00715.54
7.1.100.0070.00418.09
7.1.70.0030.00616.94
7.1.60.0060.01819.82
7.1.50.0100.01016.63
7.1.00.0070.07322.28
7.0.200.0030.00716.69
7.0.140.0100.06721.95
7.0.60.0030.07721.75
7.0.50.0030.07317.85
7.0.40.0030.04320.27
7.0.30.0170.04720.15
7.0.20.0270.05020.26
7.0.10.0070.04020.09
7.0.00.0100.08720.09
5.6.280.0000.07321.05
5.6.210.0030.08720.78
5.6.200.0100.05018.19
5.6.190.0100.05320.57
5.6.180.0530.06720.63
5.6.170.0270.06720.47
5.6.160.0030.05020.61
5.6.150.0100.08018.29
5.6.140.0100.04718.19
5.6.130.0070.08718.12
5.6.120.0000.08021.02
5.6.110.0100.08020.90
5.6.100.0100.08021.00
5.6.90.0100.09320.98
5.6.80.0200.06720.52
5.5.350.4130.04720.50
5.5.340.0100.09017.95
5.5.330.0270.06320.40
5.5.320.0270.07020.34
5.5.310.0170.04320.30
5.5.300.0100.07718.08
5.5.290.0070.06018.08
5.5.280.0130.08320.81
5.5.270.0070.04020.80
5.5.260.0200.08020.87
5.5.250.0100.07720.62
5.5.240.0000.03320.28
5.4.450.3900.04019.46
5.4.440.0100.04719.53
5.4.430.1400.06719.31
5.4.420.3630.03319.49
5.4.410.3870.03719.24
5.4.400.4200.04019.15
5.4.390.3700.03719.04
5.4.380.3870.03719.15
5.4.370.4070.03319.17
5.4.360.3900.04018.97
5.4.350.0100.04019.05
5.4.340.3900.03319.12
5.4.320.4170.05318.93
5.4.310.3900.03719.23
5.4.300.3900.03718.98
5.4.290.3600.03719.11
5.4.280.3630.03319.16
5.4.270.3500.04018.94
5.4.260.2670.04019.10
5.4.250.0000.06319.27
5.4.240.2900.03318.94
5.4.230.4200.04019.15
5.4.220.3230.03318.98
5.4.210.3870.03719.25
5.4.200.3670.03718.96
5.4.190.3900.04018.99
5.4.180.3900.03719.19
5.4.170.3570.04019.16
5.4.160.4030.03018.91
5.4.150.4230.04019.14
5.4.140.4270.03716.50
5.4.130.3770.03316.39
5.4.120.4470.03716.53
5.4.110.3900.03016.53
5.4.100.3670.02716.37
5.4.90.3630.03316.44
5.4.80.3800.04016.39
5.4.70.3770.03716.57
5.4.60.3530.03716.63
5.4.50.3930.02316.43
5.4.40.3630.03316.49
5.4.30.3830.03716.54
5.4.20.3730.03316.41
5.4.10.3730.03316.19
5.4.00.3600.04015.94
5.3.290.3700.04314.57
5.3.280.3800.03014.61
5.3.270.3670.03714.76
5.3.260.3970.03314.66
5.3.250.4300.03314.65
5.3.240.4300.04014.63
5.3.230.3470.04014.61
5.3.220.3870.03314.59
5.3.210.3730.03314.65
5.3.200.3600.03714.61
5.3.190.3630.04014.47
5.3.180.3770.04014.61
5.3.170.3300.03714.61
5.3.160.3800.04314.57
5.3.150.4030.03314.60
5.3.140.3700.03314.59
5.3.130.3830.03714.61
5.3.120.3800.04314.71
5.3.110.3870.03314.61
5.3.100.3170.03014.07
5.3.90.3570.04314.07
5.3.80.3600.03714.05
5.3.70.4200.03713.91
5.3.60.3600.03714.05
5.3.50.3430.03313.98
5.3.40.3270.04013.93
5.3.30.2530.03313.93
5.3.20.2900.03313.75
5.3.10.3770.03313.61
5.3.00.4730.04313.65
5.2.170.3130.02711.18
5.2.160.3030.03011.11
5.2.150.2500.03011.19
5.2.140.2530.02711.07
5.2.130.2200.02711.27
5.2.120.2170.03311.16
5.2.110.2800.02711.11
5.2.100.3230.02711.06
5.2.90.2730.03711.04
5.2.80.3970.02711.14
5.2.70.3200.03011.07
5.2.60.2970.02711.09
5.2.50.2870.03311.09
5.2.40.2400.02711.02
5.2.30.2630.02710.95
5.2.20.2700.03311.13
5.2.10.3130.02310.87
5.2.00.2830.02710.76
5.1.60.2800.02010.06
5.1.50.3200.02010.17
5.1.40.3070.0279.92
5.1.30.2830.02310.40
5.1.20.3100.02710.36
5.1.10.2930.02710.07
5.1.00.2830.02710.14
5.0.50.1700.0208.47
5.0.40.1330.0208.41
5.0.30.1470.0308.38
5.0.20.1430.0178.28
5.0.10.1370.0238.25
5.0.00.1530.0308.32
4.4.90.1270.0175.90
4.4.80.1170.0175.87
4.4.70.1500.0205.82
4.4.60.1400.0135.87
4.4.50.1370.0175.77
4.4.40.1630.0275.80
4.4.30.1430.0175.77
4.4.20.1430.0175.95
4.4.10.1630.0175.85
4.4.00.1670.0275.93
4.3.110.1530.0135.72
4.3.100.1400.0175.76
4.3.90.1500.0135.70
4.3.80.1400.0235.71
4.3.70.1500.0205.82
4.3.60.1170.0175.73
4.3.50.1170.0135.74
4.3.40.1530.0235.68
4.3.30.0770.0205.68
4.3.20.0770.0205.68
4.3.10.0730.0175.68
4.3.00.0930.0175.68

preferences:
50.05 ms | 401 KiB | 5 Q