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 { public function get() { return ""; } public function the() { return ""; } public function answer() { echo "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.40.0140.00018.88
8.3.30.0100.00319.09
8.3.20.0070.00020.16
8.3.10.0000.00823.65
8.3.00.0000.00819.20
8.2.170.0110.00422.96
8.2.160.0030.01020.38
8.2.150.0070.00024.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0030.00520.92
8.2.110.0060.00322.08
8.2.100.0080.00417.78
8.2.90.0040.00419.05
8.2.80.0050.00317.97
8.2.70.0000.00817.63
8.2.60.0040.00417.80
8.2.50.0040.00418.07
8.2.40.0000.00819.95
8.2.30.0040.00418.19
8.2.20.0080.00017.70
8.2.10.0050.00318.06
8.2.00.0000.00817.59
8.1.270.0050.00322.14
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0070.00323.75
8.1.230.0070.00419.00
8.1.220.0050.00217.74
8.1.210.0050.00318.77
8.1.200.0070.00317.23
8.1.190.0030.00617.35
8.1.180.0050.00318.10
8.1.170.0070.00418.27
8.1.160.0020.00521.89
8.1.150.0040.00418.60
8.1.140.0040.00417.37
8.1.130.0000.00717.87
8.1.120.0000.00717.45
8.1.110.0000.00717.33
8.1.100.0040.00417.40
8.1.90.0000.00717.48
8.1.80.0000.00817.29
8.1.70.0000.00717.29
8.1.60.0060.00317.57
8.1.50.0000.00817.48
8.1.40.0040.00417.60
8.1.30.0000.00917.63
8.1.20.0080.00017.52
8.1.10.0080.00017.61
8.1.00.0070.00017.43
8.0.300.0000.00718.77
8.0.290.0020.00517.05
8.0.280.0050.00318.40
8.0.270.0040.00417.13
8.0.260.0030.00318.33
8.0.250.0000.00717.00
8.0.240.0030.00316.84
8.0.230.0030.00316.88
8.0.220.0000.00816.87
8.0.210.0000.00716.87
8.0.200.0000.00816.88
8.0.190.0050.00217.00
8.0.180.0000.00716.92
8.0.170.0000.00716.95
8.0.160.0040.00417.02
8.0.150.0040.00416.82
8.0.140.0030.00616.89
8.0.130.0030.00313.43
8.0.120.0000.00816.89
8.0.110.0000.00716.92
8.0.100.0050.00316.78
8.0.90.0050.00316.71
8.0.80.0180.00616.91
8.0.70.0070.00016.93
8.0.60.0040.00417.03
8.0.50.0000.00716.98
8.0.30.0100.00817.07
8.0.20.0170.00917.40
8.0.10.0000.00816.95
8.0.00.0080.00916.68
7.4.330.0000.00515.00
7.4.320.0030.00316.57
7.4.300.0040.00416.53
7.4.290.0030.00316.63
7.4.280.0080.00016.41
7.4.270.0000.00716.54
7.4.260.0000.00716.51
7.4.250.0000.00716.60
7.4.240.0040.00416.53
7.4.230.0050.00216.60
7.4.220.0030.01316.49
7.4.210.0060.01216.58
7.4.200.0070.00016.69
7.4.190.0070.00016.69
7.4.160.0040.01216.59
7.4.150.0030.01517.40
7.4.140.0100.01117.86
7.4.130.0110.00816.47
7.4.120.0090.00816.68
7.4.110.0140.00316.44
7.4.100.0070.01116.51
7.4.90.0140.00516.61
7.4.80.0100.00719.39
7.4.70.0070.01416.46
7.4.60.0120.00616.47
7.4.50.0030.00316.34
7.4.40.0140.00316.67
7.4.30.0090.00916.46
7.4.00.0030.01414.97
7.3.330.0000.00513.23
7.3.320.0030.00313.39
7.3.310.0040.00416.40
7.3.300.0020.00516.41
7.3.290.0100.01016.39
7.3.280.0070.01216.36
7.3.270.0080.00817.40
7.3.260.0070.01716.48
7.3.250.0070.01016.45
7.3.240.0160.00616.52
7.3.230.0080.01216.39
7.3.210.0110.01116.41
7.3.200.0060.01519.39
7.3.190.0150.00616.38
7.3.180.0040.01116.58
7.3.170.0150.00616.43
7.3.160.0060.00916.53
7.3.120.0060.00615.00
7.2.330.0030.01516.43
7.2.320.0080.00816.61
7.2.310.0130.01016.82
7.2.300.0110.00616.54
7.2.290.0070.01516.76
7.2.60.0070.00716.96
7.2.00.0060.00319.44
7.1.200.0040.00415.84
7.1.70.0060.00317.25
7.1.60.0070.00317.27
7.1.50.0060.00916.79
7.1.00.0100.07022.30
7.0.200.0070.01116.83
7.0.140.0070.06721.96
7.0.60.0030.06721.85
7.0.50.0100.08017.86
7.0.40.0100.07320.05
7.0.30.0530.07020.20
7.0.20.0300.07720.24
7.0.10.0370.07320.33
7.0.00.0030.08720.23
5.6.280.0030.07321.00
5.6.210.0100.03720.52
5.6.200.0100.08018.29
5.6.190.0030.04720.39
5.6.180.3530.03720.40
5.6.170.0370.07720.45
5.6.160.0030.06320.64
5.6.150.0000.08718.13
5.6.140.0130.07718.21
5.6.130.0100.03718.21
5.6.120.0100.05021.00
5.6.110.0130.07721.01
5.6.100.0070.08321.00
5.6.90.0000.04321.01
5.6.80.0070.03720.41
5.5.350.3930.04020.42
5.5.340.0130.07318.05
5.5.330.0130.07020.29
5.5.320.0430.06020.13
5.5.310.0200.08020.32
5.5.300.0070.07718.08
5.5.290.0070.08717.96
5.5.280.0100.08320.97
5.5.270.0070.07720.74
5.5.260.0200.07020.88
5.5.250.0130.03020.62
5.5.240.0200.07720.23
5.4.450.0700.05719.61
5.4.440.0870.05719.39
5.4.430.0070.05719.38
5.4.420.0670.00019.32
5.4.410.0300.05318.93
5.4.400.0230.06018.81
5.4.390.0200.06018.57
5.4.380.0270.05718.79
5.4.370.0100.05318.76
5.4.360.0270.03318.48
5.4.350.0110.03712.03
5.4.340.0070.04412.02
5.4.320.0080.05012.51
5.4.310.0060.03912.51
5.4.300.0090.04412.52
5.4.290.0090.04012.50
5.4.280.0040.04212.40
5.4.270.0070.03912.40
5.4.260.0090.05012.41
5.4.250.0090.04512.40
5.4.240.0070.05012.40
5.4.230.0110.04812.40
5.4.220.0090.04712.39
5.4.210.0130.04312.39
5.4.200.0070.05212.39
5.4.190.0080.04812.39
5.4.180.0070.05112.39
5.4.170.0110.04712.40
5.4.160.0080.04512.39
5.4.150.0080.05112.39
5.4.140.0110.05612.07
5.4.130.0090.05012.06
5.4.120.0090.05612.03
5.4.110.0070.05812.02
5.4.100.0060.06412.02
5.4.90.0130.04912.02
5.4.80.0080.05312.02
5.4.70.0070.05312.01
5.4.60.0090.04912.01
5.4.50.0040.04412.02
5.4.40.0080.03212.00
5.4.30.0100.03712.00
5.4.20.0090.04212.00
5.4.10.0080.03812.00
5.4.00.0060.04211.49
5.3.290.0070.03712.80
5.3.280.0090.04212.71
5.3.270.0090.04512.73
5.3.260.0100.04512.71
5.3.250.0070.04512.72
5.3.240.0080.05012.72
5.3.230.0120.04212.71
5.3.220.0110.04912.68
5.3.210.0080.05612.68
5.3.200.0140.04412.68
5.3.190.0060.05212.68
5.3.180.0130.04412.67
5.3.170.0130.04512.66
5.3.160.0150.04312.67
5.3.150.0120.04912.67
5.3.140.0220.03912.66
5.3.130.0150.05112.66
5.3.120.0140.04812.66
5.3.110.0120.04912.66
5.3.100.0100.04612.13
5.3.90.0140.05012.11
5.3.80.0100.05112.10
5.3.70.0090.04812.10
5.3.60.0140.04512.08
5.3.50.0150.04212.04
5.3.40.0090.05112.03
5.3.30.0160.04311.99
5.3.20.0110.05611.78
5.3.10.0090.04611.73
5.3.00.0110.04711.72
5.2.170.0050.0429.23
5.2.160.0070.0339.23
5.2.150.0060.0399.23
5.2.140.0050.0389.22
5.2.130.0020.0349.18
5.2.120.0070.0299.19
5.2.110.0070.0389.20
5.2.100.0080.0379.20
5.2.90.0070.0369.20
5.2.80.0070.0399.19
5.2.70.0080.0419.19
5.2.60.0090.0339.14
5.2.50.0120.0299.10
5.2.40.0070.0349.08
5.2.30.0050.0389.07
5.2.20.0090.0459.05
5.2.10.0080.0338.95
5.2.00.0050.0358.82
5.1.60.0070.0238.10
5.1.50.0090.0318.09
5.1.40.0100.0308.08
5.1.30.0100.0248.43
5.1.20.0080.0318.45
5.1.10.0070.0298.18
5.1.00.0030.0298.18
5.0.50.0040.0206.66
5.0.40.0040.0226.52
5.0.30.0050.0326.33
5.0.20.0050.0296.30
5.0.10.0050.0206.27
5.0.00.0100.0306.27
4.4.90.0030.0214.78
4.4.80.0020.0214.76
4.4.70.0060.0174.76
4.4.60.0060.0164.75
4.4.50.0040.0174.77
4.4.40.0050.0254.71
4.4.30.0050.0194.76
4.4.20.0030.0174.84
4.4.10.0050.0214.85
4.4.00.0040.0394.76
4.3.110.0060.0314.67
4.3.100.0060.0204.66
4.3.90.0050.0224.64
4.3.80.0060.0394.59
4.3.70.0040.0184.63
4.3.60.0060.0244.63
4.3.50.0040.0204.62
4.3.40.0030.0354.54
4.3.30.0070.0493.30
4.3.20.0040.0493.28
4.3.10.0030.0213.23
4.3.00.0030.0276.38

preferences:
45.31 ms | 400 KiB | 5 Q