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 __toString() { return "4"; } public function get() { return new Answer();} public function the() { return new Answer();} public function answer() { return new Answer();} } // 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.0080.00818.11
8.3.50.0140.00722.10
8.3.40.0040.01118.88
8.3.30.0040.01119.07
8.3.20.0040.00420.24
8.3.10.0000.00822.10
8.3.00.0060.00322.33
8.2.180.0120.00416.75
8.2.170.0040.01122.96
8.2.160.0100.00720.85
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00017.63
8.2.110.0060.00322.25
8.2.100.0060.00617.66
8.2.90.0080.00019.05
8.2.80.0040.00417.97
8.2.70.0080.00017.61
8.2.60.0060.00318.04
8.2.50.0000.00818.07
8.2.40.0040.00418.09
8.2.30.0040.00417.98
8.2.20.0040.00417.70
8.2.10.0050.00217.61
8.2.00.0040.00417.66
8.1.280.0140.00725.92
8.1.270.0050.00222.18
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.96
8.1.230.0000.01119.17
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0060.00317.25
8.1.190.0060.00317.65
8.1.180.0040.00418.10
8.1.170.0040.00418.66
8.1.160.0000.00722.08
8.1.150.0040.00418.52
8.1.140.0070.00017.38
8.1.130.0000.00817.82
8.1.120.0070.00017.46
8.1.110.0040.00417.35
8.1.100.0050.00217.43
8.1.90.0040.00417.43
8.1.80.0030.00517.47
8.1.70.0000.00717.32
8.1.60.0090.00017.57
8.1.50.0080.00017.50
8.1.40.0000.00717.55
8.1.30.0050.00217.69
8.1.20.0030.00617.56
8.1.10.0000.00817.56
8.1.00.0040.00417.38
8.0.300.0030.00418.77
8.0.290.0020.00517.04
8.0.280.0070.00018.36
8.0.270.0060.00017.22
8.0.260.0000.00616.75
8.0.250.0000.00717.00
8.0.240.0040.00417.02
8.0.230.0030.00316.91
8.0.220.0040.00416.94
8.0.210.0000.00616.93
8.0.200.0000.00716.99
8.0.190.0000.00716.98
8.0.180.0100.00016.91
8.0.170.0000.00816.94
8.0.160.0000.00716.95
8.0.150.0040.00416.83
8.0.140.0000.00716.98
8.0.130.0030.00313.41
8.0.120.0030.00516.96
8.0.110.0000.00716.94
8.0.100.0040.00416.79
8.0.90.0000.00716.94
8.0.80.0140.00016.97
8.0.70.0030.00517.07
8.0.60.0040.00416.87
8.0.50.0070.00016.92
8.0.30.0060.01317.15
8.0.20.0060.01217.40
8.0.10.0000.00716.99
8.0.00.0080.01016.67
7.4.330.0350.01776.84
7.4.320.0400.02078.98
7.4.300.0280.02578.98
7.4.290.0310.03178.71
7.4.280.0320.02678.77
7.4.270.0350.02279.00
7.4.260.0510.02478.84
7.4.250.0230.02778.82
7.4.240.0290.01878.89
7.4.230.0200.02778.88
7.4.220.1300.07678.82
7.4.210.0460.05178.88
7.4.200.0170.03178.65
7.4.190.0130.04178.91
7.4.160.0690.03678.68
7.4.150.0730.04079.05
7.4.140.0680.04978.85
7.4.130.0610.07078.93
7.4.120.0740.05279.04
7.4.110.0680.03978.91
7.4.100.0780.05779.07
7.4.90.0590.05678.89
7.4.80.0690.07079.00
7.4.70.0680.04678.88
7.4.60.0650.04578.86
7.4.50.0100.02478.96
7.4.40.0270.04078.82
7.4.30.0730.04078.83
7.4.00.0270.03377.14
7.3.330.0610.051134.99
7.3.320.0460.039134.84
7.3.310.0130.03378.63
7.3.300.0260.02378.66
7.3.290.0330.06378.70
7.3.280.0800.05778.71
7.3.270.0730.08678.80
7.3.260.0560.05678.81
7.3.250.0690.05578.68
7.3.240.0450.06678.79
7.3.230.0630.05078.85
7.3.210.0630.05678.68
7.3.200.0890.06078.76
7.3.190.0990.05078.73
7.3.180.0690.05378.95
7.3.170.0860.06978.79
7.3.160.0780.05578.63
7.3.120.0330.02976.93
7.2.330.0800.03279.08
7.2.320.0780.04379.07
7.2.310.0610.07679.24
7.2.300.0560.05479.15
7.2.290.0660.05678.76
7.2.80.1100.03078.15
7.2.60.1350.02978.88
7.2.01.3520.02780.90
7.1.200.1160.02677.74
7.1.100.3700.00643.07
7.1.70.1080.02979.09
7.1.60.0000.03578.81
7.1.50.0110.07278.67
7.1.00.0170.10084.24
7.0.200.2450.02678.27
7.0.140.0130.09383.97
7.0.70.0100.08783.68
7.0.60.0130.09083.77
7.0.50.0200.10384.04
7.0.40.0070.11324.14
7.0.30.0070.11724.02
7.0.20.0070.11724.17
7.0.10.0230.10024.12
7.0.00.0200.09724.12
5.6.280.0270.08079.94
5.6.220.0270.10777.45
5.6.210.0170.06777.49
5.6.200.0270.10377.79
5.6.190.0300.10377.87
5.6.180.0230.10777.87
5.6.170.0370.09377.92
5.6.160.0270.10777.87
5.6.150.0300.10377.92
5.6.140.0200.11777.90
5.6.130.0270.10077.85
5.6.120.0330.10077.85
5.6.110.0430.09077.92
5.6.100.0300.10077.99
5.6.90.0200.11777.85
5.6.80.0200.10077.21
5.6.70.0270.09077.15
5.6.60.0200.07077.20
5.6.50.0270.08377.32
5.6.40.0370.09077.42
5.6.30.0230.10377.30
5.6.20.0330.09777.19
5.6.10.0170.09378.86
5.6.00.0300.08077.19
5.5.360.0330.06377.50
5.5.350.0170.06077.52
5.5.340.0270.10377.84
5.5.330.0330.10077.84
5.5.320.0230.11377.95
5.5.310.0300.09779.95
5.5.300.0330.10777.93
5.5.290.0200.06777.99
5.5.280.0230.06077.97
5.5.270.0370.08077.79
5.5.260.0230.10777.95
5.5.250.0230.09077.67
5.5.240.0300.09377.31
5.5.230.0230.06777.32
5.5.220.0200.10377.28
5.5.210.0200.10077.37
5.5.200.0370.09077.30
5.5.190.0170.06079.02
5.5.180.0270.10777.21
5.5.160.0170.10079.29
5.5.150.0130.06077.27
5.5.140.0300.10379.04
5.5.130.0300.10377.28
5.5.120.0270.10077.29
5.5.110.0170.08377.33
5.5.100.0270.09777.16
5.5.90.0230.09377.17
5.5.80.0130.06376.98
5.5.70.0070.10777.15
5.5.60.0300.10078.86
5.5.50.0230.10377.00
5.5.40.0170.11077.02
5.5.30.0270.10377.13
5.5.20.0370.09078.80
5.5.10.0230.08377.02
5.5.00.0270.09077.14
5.4.450.0200.11378.41
5.4.440.0300.10376.66
5.4.430.0230.10076.63
5.4.420.0230.07078.70
5.4.410.0230.10776.46
5.4.400.0230.09376.31
5.4.390.0330.07776.47
5.4.380.0130.10778.27
5.4.370.0300.09777.89
5.4.360.0300.10076.47
5.4.350.0100.07378.27
5.4.340.0330.09776.18
5.4.320.0270.08777.88
5.4.310.0100.07076.17
5.4.300.0370.09078.28
5.4.290.0230.09778.21
5.4.280.0270.06776.38
5.4.270.0200.08078.55
5.4.260.0170.10776.40
5.4.250.0170.05776.30
5.4.240.0270.07377.90
5.4.230.0270.07377.97
5.4.220.0270.07376.13
5.4.210.0270.10078.10
5.4.200.0300.05778.38
5.4.190.0170.11076.34
5.4.180.0170.09777.96
5.4.170.0300.09776.13
5.4.160.0230.09378.22
5.4.150.0170.10376.11
5.4.140.0200.09073.78
5.4.130.0300.09375.46
5.4.120.0200.11075.24
5.4.110.0230.08773.66
5.4.100.0200.05775.63
5.4.90.0170.11375.54
5.4.80.0230.09373.64
5.4.70.0130.09775.29
5.4.60.0300.09373.81
5.4.50.0200.09773.77
5.4.40.0230.10773.80
5.4.30.0300.09373.69
5.4.20.0330.07773.59
5.4.10.0200.09775.50
5.4.00.0170.10373.13
5.3.290.0270.12776.72
5.3.280.0130.13077.50
5.3.270.0200.13077.61
5.3.260.0170.12776.51
5.3.250.0270.06076.61
5.3.240.0430.09377.11
5.3.230.0200.11077.78
5.3.220.0230.08376.71
5.3.210.0270.06077.49
5.3.200.0230.10377.30
5.3.190.0130.09377.70
5.3.180.0200.07377.54
5.3.170.0270.12777.18
5.3.160.0230.11777.23
5.3.150.0130.10377.06
5.3.140.0330.10777.79
5.3.130.0270.12377.93
5.3.120.0630.09077.64
5.3.110.0270.13076.54
5.3.100.0170.09775.91
5.3.90.0200.07076.42
5.3.80.0330.11375.86
5.3.70.0400.10775.87
5.3.60.0230.12377.11
5.3.50.0230.07376.82
5.3.40.0200.11076.05
5.3.30.0230.12076.71
5.3.20.0170.09376.38
5.3.10.0170.12075.59
5.3.00.0230.11077.07
5.2.170.0130.03726.37
5.2.160.0030.03326.33
5.2.150.0130.06026.15
5.2.140.0100.07326.32
5.2.130.0100.06726.18
5.2.120.0100.06326.22
5.2.110.0100.06726.26
5.2.100.0070.07026.33
5.2.90.0130.05326.25
5.2.80.0130.06326.28
5.2.70.0070.05026.28
5.2.60.0130.06726.17
5.2.50.0130.06726.27
5.2.40.0100.06726.13
5.2.30.0100.07026.14
5.2.20.0100.06326.27
5.2.10.0170.07027.70
5.2.00.0070.06025.87
5.1.60.0100.04327.65
5.1.50.0170.06027.56
5.1.40.0100.06727.49
5.1.30.0070.07328.05
5.1.20.0070.07327.89
5.1.10.0170.06027.54
5.1.00.0130.06027.68
5.0.50.0100.06027.69
5.0.40.0100.05727.49
5.0.30.0100.07027.29
5.0.20.0030.05327.26
5.0.10.0100.05727.20
5.0.00.0130.08036.71
4.4.90.0030.02711.34
4.4.80.0000.03311.34
4.4.70.0070.03011.34
4.4.60.0000.03311.34
4.4.50.0000.02311.34
4.4.40.0000.05711.34
4.4.30.0030.03311.34
4.4.20.0000.03711.34
4.4.10.0000.03711.34
4.4.00.0000.05311.34
4.3.110.0000.03711.34
4.3.100.0000.03311.34
4.3.90.0000.03711.34
4.3.80.0000.05311.34
4.3.70.0000.03711.34
4.3.60.0100.02711.34
4.3.50.0030.02011.34
4.3.40.0000.05011.34
4.3.30.0000.03011.34
4.3.20.0000.03711.34
4.3.10.0000.03311.34
4.3.00.0030.03011.34

preferences:
42.26 ms | 401 KiB | 5 Q