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 $this->get()->the()->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.1130.03695.70
8.3.50.1030.02896.57
8.3.40.0420.01347.82
8.3.30.0400.02348.07
8.3.20.0170.01049.42
8.3.10.0190.00351.09
8.3.00.0090.00947.45
8.2.180.0230.01026.04
8.2.170.0220.01628.13
8.2.160.0070.01729.70
8.2.150.0100.00328.55
8.2.140.0080.00629.63
8.2.130.0140.00030.32
8.2.120.0130.00030.15
8.2.110.0140.00429.41
8.2.100.0150.00726.91
8.2.90.0110.00328.20
8.2.80.0030.01027.15
8.2.70.0150.00026.63
8.2.60.0120.00027.05
8.2.50.0110.00426.88
8.2.40.0030.01028.07
8.2.30.0090.00327.32
8.2.20.0040.00727.05
8.2.10.0040.00727.89
8.2.00.0090.00327.00
8.1.280.0240.01025.92
8.1.270.0070.00731.86
8.1.260.0120.00328.25
8.1.250.0100.00331.75
8.1.240.0170.00731.91
8.1.230.0100.01030.20
8.1.220.0080.00426.80
8.1.210.0040.01126.73
8.1.200.0090.00626.60
8.1.190.0100.00326.91
8.1.180.0200.00026.61
8.1.170.0150.00327.95
8.1.160.0040.00731.45
8.1.150.0120.00328.11
8.1.140.0080.00326.85
8.1.130.0070.00427.23
8.1.120.0060.00626.79
8.1.110.0090.00326.75
8.1.100.0080.00326.76
8.1.90.0030.01026.80
8.1.80.0080.00326.95
8.1.70.0070.00426.88
8.1.60.0090.00326.98
8.1.50.0060.00626.82
8.1.40.0080.00426.90
8.1.30.0030.01027.02
8.1.20.0060.00627.03
8.1.10.0060.00626.99
8.1.00.0110.00027.00
8.0.300.0070.00726.35
8.0.290.0090.00326.30
8.0.280.0070.00427.48
8.0.270.0030.00726.36
8.0.260.0030.00726.43
8.0.250.0030.00926.05
8.0.240.0000.01226.10
8.0.230.0040.00726.22
8.0.220.0070.00326.16
8.0.210.0030.00726.02
8.0.200.0070.00426.06
8.0.190.0040.00826.18
8.0.180.0070.00726.11
8.0.170.0110.00026.13
8.0.160.0040.00726.16
8.0.150.0080.00426.09
8.0.140.0080.00426.04
8.0.130.0120.00022.61
8.0.120.0100.00326.11
8.0.110.0040.00825.97
8.0.100.0070.00426.03
8.0.90.0080.00426.14
8.0.80.0100.01926.11
8.0.70.0090.00325.88
8.0.60.0080.00425.91
8.0.50.0040.00725.89
8.0.30.0130.01526.32
8.0.20.0200.01326.08
8.0.10.0080.00426.17
8.0.00.0170.01325.99
7.4.330.0050.00015.00
7.4.320.0050.00316.50
7.4.300.0000.00616.50
7.4.290.0060.00016.52
7.4.280.0030.00316.61
7.4.270.0080.00016.42
7.4.260.0000.00716.54
7.4.250.0060.00316.55
7.4.240.0020.00516.56
7.4.230.0000.00716.36
7.4.220.0060.01216.63
7.4.210.0060.01216.55
7.4.200.0070.00016.36
7.4.190.0030.00516.58
7.4.160.0120.00316.56
7.4.150.0070.01017.40
7.4.140.0110.00617.86
7.4.130.0120.00816.53
7.4.120.0120.00616.54
7.4.110.0000.01716.47
7.4.100.0030.01816.82
7.4.90.0170.00716.45
7.4.80.0110.01119.39
7.4.70.0070.01116.70
7.4.60.0160.00716.48
7.4.50.0000.00716.64
7.4.40.0000.01622.77
7.4.30.0060.01016.59
7.4.00.0060.01014.97
7.3.330.0000.00613.23
7.3.320.0050.00013.30
7.3.310.0000.00716.22
7.3.300.0080.00016.38
7.3.290.0070.00716.31
7.3.280.0060.00916.35
7.3.270.0140.00317.40
7.3.260.0120.00616.50
7.3.250.0080.01016.36
7.3.240.0040.01416.48
7.3.230.0100.01316.53
7.3.210.0070.01016.48
7.3.200.0030.02219.39
7.3.190.0100.01716.41
7.3.180.0060.01016.54
7.3.170.0030.01316.56
7.3.160.0100.01016.60
7.3.120.0040.00815.13
7.2.330.0120.00416.66
7.2.320.0060.01016.41
7.2.310.0160.00816.72
7.2.300.0090.00916.84
7.2.290.0140.00316.50
7.2.110.0080.00616.50
7.2.60.0070.00717.04
7.2.00.0030.00719.28
7.1.200.0070.00715.91
7.1.100.0000.01117.86
7.1.70.0000.00717.21
7.1.60.0090.00919.46
7.1.50.0110.01116.94
7.1.00.0070.07322.46
7.0.200.0070.00016.85
7.0.140.0030.07322.00
7.0.60.0100.08320.04
7.0.50.0100.07717.89
7.0.40.0100.06720.27
7.0.30.0300.08020.27
7.0.20.0200.07720.16
7.0.10.0130.07720.10
7.0.00.0030.05720.08
5.6.280.0000.07721.13
5.6.210.0100.08020.62
5.6.200.0030.05018.23
5.6.190.0130.06720.39
5.6.180.0270.07320.55
5.6.170.0230.03720.47
5.6.160.0130.06320.52
5.6.150.0100.05718.19
5.6.140.0000.04718.16
5.6.130.0130.08318.33
5.6.120.0000.08721.16
5.6.110.0030.07720.98
5.6.100.0100.05721.12
5.6.90.0070.05721.13
5.6.80.0070.03720.54
5.6.70.4570.03720.46
5.5.350.0230.06320.46
5.5.340.0100.07717.95
5.5.330.0070.07720.41
5.5.320.0300.07020.14
5.5.310.0200.05020.27
5.5.300.0070.05718.06
5.5.290.0070.08017.93
5.5.280.0070.07320.79
5.5.270.0200.06020.86
5.5.260.0130.07720.88
5.5.250.0130.07020.62
5.5.240.0270.03320.27
5.4.450.0900.05019.30
5.4.440.0700.05719.57
5.4.430.0600.05319.62
5.4.420.0800.06319.47
5.4.410.0730.05319.49
5.4.400.0830.05019.35
5.4.390.0770.05319.13
5.4.380.0330.05318.63
5.4.370.0330.05018.78
5.4.360.0300.05318.59
5.4.350.0470.05018.79
5.4.340.0330.05018.48
5.4.320.0040.03812.51
5.4.310.0060.03812.50
5.4.300.0060.04212.51
5.4.290.0050.05212.49
5.4.280.0080.03812.39
5.4.270.0060.03912.39
5.4.260.0080.03712.39
5.4.250.0080.04312.39
5.4.240.0070.04012.39
5.4.230.0080.03812.38
5.4.220.0070.03712.38
5.4.210.0060.03912.38
5.4.200.0080.04412.38
5.4.190.0090.04512.38
5.4.180.0070.04812.38
5.4.170.0070.04212.39
5.4.160.0120.03912.39
5.4.150.0080.03812.38
5.4.140.0100.04012.06
5.4.130.0060.04312.05
5.4.120.0090.05112.01
5.4.110.0050.03712.00
5.4.100.0060.03712.00
5.4.90.0030.04412.01
5.4.80.0090.03712.00
5.4.70.0080.03512.00
5.4.60.0060.03912.00
5.4.50.0060.03712.00
5.4.40.0060.03511.98
5.4.30.0020.05111.98
5.4.20.0040.03811.99
5.4.10.0070.03411.98
5.4.00.0090.03311.48
5.3.290.0030.04412.80
5.3.280.0050.04112.71
5.3.270.0070.03812.73
5.3.260.0080.03912.72
5.3.250.0100.03312.71
5.3.240.0070.03712.72
5.3.230.0060.03912.71
5.3.220.0080.03612.68
5.3.210.0040.04612.68
5.3.200.0040.04312.68
5.3.190.0090.03912.68
5.3.180.0030.04112.67
5.3.170.0070.04612.67
5.3.160.0050.04312.67
5.3.150.0090.03812.68
5.3.140.0090.05612.66
5.3.130.0070.04212.66
5.3.120.0060.04512.66
5.3.110.0100.03812.65
5.3.100.0080.03812.14
5.3.90.0070.03912.12
5.3.80.0060.04012.11
5.3.70.0080.04112.11
5.3.60.0050.03912.10
5.3.50.0060.03712.04
5.3.40.0070.03712.04
5.3.30.0090.03512.00
5.3.20.0040.03911.79
5.3.10.0070.03811.75
5.3.00.0080.04011.73
5.2.170.0040.0479.23
5.2.160.0110.0269.23
5.2.150.0070.0449.23
5.2.140.0080.0439.23
5.2.130.0070.0399.19
5.2.120.0090.0369.19
5.2.110.0060.0369.20
5.2.100.0070.0409.19
5.2.90.0040.0359.20
5.2.80.0070.0319.19
5.2.70.0050.0339.19
5.2.60.0040.0349.14
5.2.50.0110.0569.11
5.2.40.0060.0339.08
5.2.30.0070.0319.07
5.2.20.0060.0299.05
5.2.10.0050.0328.96
5.2.00.0050.0318.82
5.1.60.0040.0258.11
5.1.50.0060.0288.10
5.1.40.0040.0288.08
5.1.30.0080.0368.43
5.1.20.0050.0398.45
5.1.10.0040.0298.18
5.1.00.0020.0338.18
5.0.50.0020.0226.65
5.0.40.0020.0226.52
5.0.30.0030.0366.33
5.0.20.0020.0226.30
5.0.10.0030.0236.27
5.0.00.0070.0286.27
4.4.90.0040.0144.78
4.4.80.0040.0144.75
4.4.70.0050.0134.76
4.4.60.0020.0164.75
4.4.50.0030.0154.77
4.4.40.0030.0264.71
4.4.30.0050.0204.76
4.4.20.0030.0234.84
4.4.10.0010.0254.85
4.4.00.0030.0344.76
4.3.110.0020.0184.67
4.3.100.0020.0164.66
4.3.90.0040.0164.63
4.3.80.0030.0244.58
4.3.70.0040.0154.63
4.3.60.0040.0154.63
4.3.50.0020.0184.63
4.3.40.0060.0284.54
4.3.30.0060.0213.30
4.3.20.0030.0213.28
4.3.10.0030.0163.23
4.3.00.0170.01310.54

preferences:
58.17 ms | 401 KiB | 5 Q