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 Answer) { 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 "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.60.0110.00316.50
8.3.50.0100.01021.92
8.3.40.0110.00318.97
8.3.30.0060.00819.22
8.3.20.0070.00020.16
8.3.10.0040.00423.63
8.3.00.0040.00419.25
8.2.180.0110.01118.16
8.2.170.0030.01722.96
8.2.160.0100.00320.53
8.2.150.0000.00724.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0000.00820.81
8.2.110.0090.00021.93
8.2.100.0070.00417.66
8.2.90.0000.00819.22
8.2.80.0040.00417.97
8.2.70.0000.00817.50
8.2.60.0040.00418.03
8.2.50.0080.00018.07
8.2.40.0040.00419.95
8.2.30.0040.00418.14
8.2.20.0000.00717.58
8.2.10.0000.00717.88
8.2.00.0080.00017.73
8.1.280.0070.00725.92
8.1.270.0060.00322.01
8.1.260.0030.00526.35
8.1.250.0080.00028.09
8.1.240.0060.00323.78
8.1.230.0080.00419.16
8.1.220.0030.00617.74
8.1.210.0000.00918.77
8.1.200.0050.00517.35
8.1.190.0030.00617.23
8.1.180.0060.00318.10
8.1.170.0030.00918.50
8.1.160.0000.00722.01
8.1.150.0000.00718.55
8.1.140.0070.00017.51
8.1.130.0000.00717.88
8.1.120.0020.00517.49
8.1.110.0000.00817.49
8.1.100.0000.00817.41
8.1.90.0000.00717.46
8.1.80.0040.00417.46
8.1.70.0000.00717.29
8.1.60.0090.00017.58
8.1.50.0000.00817.56
8.1.40.0030.00617.41
8.1.30.0000.00817.61
8.1.20.0050.00317.54
8.1.10.0030.00517.50
8.1.00.0000.00817.36
8.0.300.0020.00518.77
8.0.290.0050.00217.05
8.0.280.0000.00718.46
8.0.270.0000.00717.32
8.0.260.0080.00017.27
8.0.250.0000.00716.99
8.0.240.0030.00317.04
8.0.230.0040.00417.01
8.0.220.0060.00316.95
8.0.210.0040.00416.97
8.0.200.0040.00417.01
8.0.190.0030.00516.93
8.0.180.0030.00616.88
8.0.170.0000.00816.93
8.0.160.0040.00416.94
8.0.150.0050.00216.94
8.0.140.0040.00716.87
8.0.130.0000.00613.37
8.0.120.0000.00816.91
8.0.110.0050.00217.01
8.0.100.0040.00416.83
8.0.90.0040.00416.79
8.0.80.0160.00316.91
8.0.70.0000.00716.83
8.0.60.0040.00416.78
8.0.50.0050.00216.84
8.0.30.0110.01017.06
8.0.20.0130.00917.41
8.0.10.0000.00717.14
8.0.00.0080.01116.88
7.4.330.0050.00015.17
7.4.320.0000.00616.51
7.4.300.0070.00016.42
7.4.290.0070.00016.46
7.4.280.0000.00916.41
7.4.270.0040.00416.61
7.4.260.0030.00316.53
7.4.250.0040.00416.37
7.4.240.0060.00216.43
7.4.230.0070.00016.58
7.4.220.0070.01016.69
7.4.210.0110.00516.59
7.4.200.0000.00716.41
7.4.190.0050.00316.69
7.4.160.0110.00516.52
7.4.150.0090.00917.40
7.4.140.0110.01117.86
7.4.130.0050.01516.67
7.4.120.0110.00716.71
7.4.110.0110.00716.55
7.4.100.0150.00616.49
7.4.90.0000.01716.39
7.4.80.0030.01719.39
7.4.70.0070.01016.63
7.4.60.0060.01216.56
7.4.50.0090.00016.50
7.4.40.0060.01016.38
7.4.30.0030.01216.70
7.4.00.0030.01414.76
7.3.330.0050.00013.36
7.3.320.0000.00513.14
7.3.310.0000.00716.46
7.3.300.0070.00016.23
7.3.290.0060.01216.43
7.3.280.0040.01416.37
7.3.270.0180.00017.40
7.3.260.0070.01416.48
7.3.250.0080.00916.41
7.3.240.0070.01016.36
7.3.230.0080.00816.60
7.3.210.0110.00516.36
7.3.200.0160.00619.39
7.3.190.0070.01416.46
7.3.180.0030.01316.39
7.3.170.0130.00916.50
7.3.160.0050.01116.34
7.3.120.0070.00714.83
7.3.10.0130.00016.06
7.3.00.0060.00916.39
7.2.330.0070.01716.45
7.2.320.0080.00916.59
7.2.310.0090.01216.68
7.2.300.0120.00616.68
7.2.290.0120.00616.59
7.2.130.0030.01016.51
7.2.120.0040.00916.23
7.2.110.0000.01816.59
7.2.100.0040.01116.46
7.2.90.0050.00516.40
7.2.80.0080.00316.61
7.2.70.0060.00615.97
7.2.60.0100.00516.59
7.2.50.0120.00316.38
7.2.40.0080.01216.60
7.2.30.0090.00916.35
7.2.20.0150.00016.55
7.2.10.0060.00916.72
7.2.00.0050.00918.02
7.1.250.0040.01115.61
7.1.200.0120.00315.75
7.1.100.0110.00717.97
7.1.70.0040.00417.22
7.1.60.0110.01519.46
7.1.50.0140.01016.99
7.1.00.0030.07722.28
7.0.200.0080.00416.82
7.0.140.0000.07022.01
7.0.60.0000.07320.04
7.0.50.0100.04717.95
7.0.40.0030.04720.10
7.0.30.0200.04020.20
7.0.20.0300.04320.33
7.0.10.0070.07020.12
7.0.00.0030.04320.30
5.6.280.0070.07321.00
5.6.210.0130.07720.77
5.6.200.0000.05718.18
5.6.190.0070.04020.64
5.6.180.0100.05320.58
5.6.170.0130.04720.54
5.6.160.0130.07020.48
5.6.150.0100.07018.14
5.6.140.0230.07018.24
5.6.130.0070.08018.27
5.6.120.0070.04021.13
5.6.110.0030.06321.15
5.6.100.0130.08021.01
5.6.90.0070.05721.03
5.6.80.0070.07720.45
5.5.350.0030.08020.39
5.5.340.0130.07017.99
5.5.330.0200.07320.47
5.5.320.0330.06720.36
5.5.310.0270.06320.23
5.5.300.0070.08318.08
5.5.290.0070.08017.95
5.5.280.0100.06320.86
5.5.270.0100.05320.74
5.5.260.0030.05020.78
5.5.250.0030.08020.44
5.5.240.0030.03720.16
5.4.450.0570.06019.20
5.4.440.0630.07019.48
5.4.430.0670.05719.47
5.4.420.0600.06019.19
5.4.410.1070.04319.07
5.4.400.0900.06018.84
5.4.390.0670.05319.29
5.4.380.0330.05718.72
5.4.370.0870.04718.73
5.4.360.0200.04318.75
5.4.350.0370.06018.60
5.4.340.0400.06718.55
5.4.320.0050.03812.51
5.4.310.0080.04012.50
5.4.300.0080.03512.51
5.4.290.0080.03512.50
5.4.280.0070.03412.40
5.4.270.0050.03812.40
5.4.260.0050.04012.41
5.4.250.0050.03912.41
5.4.240.0070.03612.40
5.4.230.0090.03612.40
5.4.220.0060.04812.39
5.4.210.0070.06612.40
5.4.200.0100.05512.39
5.4.190.0100.05712.39
5.4.180.0070.03812.39
5.4.170.0060.03712.40
5.4.160.0110.04612.40
5.4.150.0100.04812.39
5.4.140.0070.05012.08
5.4.130.0130.05312.06
5.4.120.0080.05612.02
5.4.110.0090.05012.02
5.4.100.0070.04712.02
5.4.90.0050.04912.02
5.4.80.0040.05212.02
5.4.70.0070.04912.02
5.4.60.0090.04612.02
5.4.50.0130.04212.01
5.4.40.0050.04012.01
5.4.30.0090.03712.00
5.4.20.0110.03912.00
5.4.10.0050.04312.00
5.4.00.0020.04511.49
5.3.290.0120.04012.80
5.3.280.0090.03912.71
5.3.270.0140.03912.72
5.3.260.0050.05312.72
5.3.250.0060.04512.72
5.3.240.0160.03612.72
5.3.230.0090.04412.71
5.3.220.0130.03612.68
5.3.210.0050.04412.68
5.3.200.0060.03712.68
5.3.190.0120.03412.68
5.3.180.0080.04012.67
5.3.170.0080.04212.67
5.3.160.0130.03712.67
5.3.150.0100.04512.67
5.3.140.0100.04212.66
5.3.130.0080.04212.66
5.3.120.0050.04612.66
5.3.110.0110.04112.66
5.3.100.0020.04012.13
5.3.90.0060.03612.11
5.3.80.0100.04112.10
5.3.70.0090.03712.10
5.3.60.0060.03712.09
5.3.50.0090.03612.03
5.3.40.0070.03812.03
5.3.30.0060.03611.99
5.3.20.0060.03711.78
5.3.10.0070.03511.74
5.3.00.0070.03811.72
5.2.170.0090.0409.23
5.2.160.0070.0419.23
5.2.150.0060.0439.22
5.2.140.0080.0349.22
5.2.130.0070.0319.18
5.2.120.0090.0299.18
5.2.110.0050.0309.19
5.2.100.0040.0319.19
5.2.90.0050.0309.19
5.2.80.0060.0309.19
5.2.70.0020.0409.19
5.2.60.0070.0299.13
5.2.50.0050.0309.10
5.2.40.0060.0279.08
5.2.30.0050.0339.06
5.2.20.0020.0419.04
5.2.10.0040.0388.95
5.2.00.0080.0378.82
5.1.60.0040.0348.09
5.1.50.0060.0318.09
5.1.40.0090.0208.07
5.1.30.0020.0288.43
5.1.20.0060.0268.45
5.1.10.0060.0248.17
5.1.00.0070.0288.17
5.0.50.0050.0206.65
5.0.40.0040.0306.52
5.0.30.0050.0346.32
5.0.20.0020.0216.30
5.0.10.0020.0216.27
5.0.00.0020.0326.26
4.4.90.0020.0174.78
4.4.80.0020.0164.76
4.4.70.0040.0144.76
4.4.60.0010.0184.75
4.4.50.0050.0154.77
4.4.40.0030.0304.71
4.4.30.0020.0214.76
4.4.20.0020.0234.84
4.4.10.0040.0214.85
4.4.00.0040.0284.76
4.3.110.0040.0154.67
4.3.100.0030.0164.67
4.3.90.0040.0144.64
4.3.80.0060.0224.59
4.3.70.0030.0154.63
4.3.60.0040.0144.63
4.3.50.0010.0194.63
4.3.40.0040.0274.54
4.3.30.0030.0183.30
4.3.20.0010.0173.28
4.3.10.0020.0183.23
4.3.00.0130.0236.93

preferences:
55 ms | 401 KiB | 5 Q