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 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.0080.01216.62
8.3.50.0170.00521.93
8.3.40.0070.00718.57
8.3.30.0100.00319.09
8.3.20.0000.00720.29
8.3.10.0040.00423.51
8.3.00.0050.00319.14
8.2.180.0090.00616.50
8.2.170.0090.00622.96
8.2.160.0070.00720.58
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00420.67
8.2.110.0110.00022.08
8.2.100.0040.00717.72
8.2.90.0040.00419.27
8.2.80.0050.00317.97
8.2.70.0080.00017.50
8.2.60.0060.00318.04
8.2.50.0000.00918.07
8.2.40.0030.00520.00
8.2.30.0050.00319.95
8.2.20.0050.00317.70
8.2.10.0040.00417.99
8.2.00.0050.00217.59
8.1.280.0190.00325.92
8.1.270.0000.00822.05
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.78
8.1.230.0000.01120.89
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0040.00417.22
8.1.190.0080.00017.23
8.1.180.0000.00819.01
8.1.170.0040.00918.28
8.1.160.0000.00721.93
8.1.150.0050.00218.60
8.1.140.0070.00017.41
8.1.130.0030.00317.82
8.1.120.0000.00717.32
8.1.110.0000.00817.45
8.1.100.0070.00017.52
8.1.90.0000.00817.48
8.1.80.0000.00717.46
8.1.70.0070.00017.43
8.1.60.0000.01117.54
8.1.50.0000.00917.43
8.1.40.0030.00517.47
8.1.30.0050.00317.67
8.1.20.0050.00317.56
8.1.10.0000.00717.52
8.1.00.0000.00817.48
8.0.300.0030.00619.83
8.0.290.0000.00717.18
8.0.280.0070.00018.35
8.0.270.0030.00317.27
8.0.260.0030.00617.29
8.0.250.0060.00316.98
8.0.240.0030.00316.89
8.0.230.0030.00316.98
8.0.220.0060.00016.86
8.0.210.0040.00416.93
8.0.200.0090.00017.08
8.0.190.0040.00416.93
8.0.180.0000.00716.86
8.0.170.0040.00416.87
8.0.160.0050.00217.07
8.0.150.0030.00316.95
8.0.140.0050.00516.96
8.0.130.0030.00513.22
8.0.120.0030.00516.82
8.0.110.0040.00416.85
8.0.100.0030.00616.90
8.0.90.0070.00016.92
8.0.80.0060.00916.93
8.0.70.0030.00516.93
8.0.60.0050.00217.07
8.0.50.0050.00217.00
8.0.30.0100.00917.16
8.0.20.0130.01117.40
8.0.10.0070.00017.15
8.0.00.0070.01216.85
7.4.330.0000.00515.14
7.4.320.0030.00316.60
7.4.300.0000.00816.53
7.4.290.0030.00316.61
7.4.280.0050.00316.54
7.4.270.0000.00716.60
7.4.260.0030.00316.46
7.4.250.0000.00716.41
7.4.240.0020.00516.49
7.4.230.0030.00316.62
7.4.220.0120.00916.53
7.4.210.0090.00716.54
7.4.200.0030.00516.45
7.4.190.0040.00416.48
7.4.160.0090.00616.43
7.4.150.0070.01017.40
7.4.140.0150.01017.86
7.4.130.0100.00816.62
7.4.120.0140.00416.56
7.4.110.0070.01016.55
7.4.100.0060.01116.55
7.4.90.0090.00916.39
7.4.80.0090.01319.39
7.4.70.0000.01616.59
7.4.60.0110.00616.30
7.4.50.0080.00016.43
7.4.40.0060.01116.54
7.4.30.0100.00716.36
7.4.00.0040.01414.89
7.3.330.0000.00513.29
7.3.320.0060.00013.32
7.3.310.0070.00016.39
7.3.300.0040.00416.40
7.3.290.0120.00816.35
7.3.280.0100.00916.33
7.3.270.0120.00817.40
7.3.260.0030.02016.56
7.3.250.0110.00616.36
7.3.240.0100.00716.31
7.3.230.0120.00716.54
7.3.210.0090.00916.55
7.3.200.0140.00619.39
7.3.190.0110.00616.41
7.3.180.0090.00616.44
7.3.170.0100.00716.53
7.3.160.0060.00916.57
7.3.120.0030.01014.69
7.2.330.0090.00916.64
7.2.320.0100.00716.68
7.2.310.0100.00716.61
7.2.300.0100.00716.39
7.2.290.0030.01516.44
7.2.80.0030.01016.55
7.2.60.0070.01016.94
7.2.00.0040.00819.55
7.1.200.0080.00415.63
7.1.100.0060.00618.22
7.1.70.0080.00017.23
7.1.60.0160.00619.46
7.1.50.0060.01816.80
7.1.00.0100.07022.30
7.0.200.0040.01116.47
7.0.140.0030.07022.00
7.0.60.0100.06719.93
7.0.50.0100.07317.96
7.0.40.0030.06319.96
7.0.30.0270.07320.23
7.0.20.0270.06320.19
7.0.10.0100.05720.09
7.0.00.0030.04320.19
5.6.280.0000.07721.00
5.6.210.0030.07720.52
5.6.200.0070.04018.18
5.6.190.0130.08020.67
5.6.180.0070.04720.42
5.6.170.0300.06020.53
5.6.160.0030.04320.43
5.6.150.0070.08318.22
5.6.140.0100.07718.28
5.6.130.0000.04718.17
5.6.120.0070.08721.16
5.6.110.0030.09021.02
5.6.100.0030.04721.15
5.6.90.0070.08721.02
5.6.80.0100.05020.37
5.5.350.0330.07320.34
5.5.340.0030.08317.96
5.5.330.0170.03320.30
5.5.320.0270.04020.30
5.5.310.0330.07320.28
5.5.300.0130.08017.98
5.5.290.0000.07017.97
5.5.280.0100.05320.66
5.5.270.0030.04320.88
5.5.260.0070.06020.80
5.5.250.0130.04320.59
5.5.240.0100.07020.38
5.4.450.0770.05719.57
5.4.440.0670.06019.16
5.4.430.0330.04719.55
5.4.420.0730.07019.58
5.4.410.0700.05719.21
5.4.400.0800.04719.31
5.4.390.0630.05319.22
5.4.380.0170.06318.55
5.4.370.0430.04718.78
5.4.360.0300.05718.57
5.4.350.0470.06718.77
5.4.340.0370.04318.69
5.4.320.0070.03812.51
5.4.310.0040.03912.50
5.4.300.0070.03812.51
5.4.290.0130.07312.50
5.4.280.0150.06612.40
5.4.270.0210.05712.40
5.4.260.0080.04912.40
5.4.250.0090.06112.40
5.4.240.0110.08712.40
5.4.230.0050.05712.40
5.4.220.0130.09812.39
5.4.210.0190.10412.39
5.4.200.0240.08012.39
5.4.190.0100.05212.39
5.4.180.0070.04312.39
5.4.170.0090.05912.40
5.4.160.0150.06412.40
5.4.150.0160.08512.39
5.4.140.0120.07212.08
5.4.130.0120.06412.07
5.4.120.0130.06812.02
5.4.110.0130.05412.02
5.4.100.0110.05612.02
5.4.90.0080.05712.02
5.4.80.0110.05912.02
5.4.70.0110.05612.02
5.4.60.0190.08212.02
5.4.50.0130.04512.01
5.4.40.0100.06012.00
5.4.30.0050.05812.00
5.4.20.0090.04412.00
5.4.10.0070.06012.00
5.4.00.0120.06911.49
5.3.290.0060.04012.80
5.3.280.0200.07212.71
5.3.270.0090.07812.73
5.3.260.0140.06712.72
5.3.250.0180.06512.72
5.3.240.0270.08612.72
5.3.230.0140.09212.71
5.3.220.0160.06712.68
5.3.210.0170.07512.68
5.3.200.0160.08312.68
5.3.190.0050.05012.68
5.3.180.0130.05312.68
5.3.170.0120.05212.67
5.3.160.0160.07412.67
5.3.150.0230.07812.67
5.3.140.0140.06012.66
5.3.130.0100.07012.66
5.3.120.0280.10312.66
5.3.110.0230.08112.66
5.3.100.0080.07012.13
5.3.90.0100.08512.11
5.3.80.0250.08812.09
5.3.70.0180.07512.10
5.3.60.0180.06912.09
5.3.50.0130.07212.03
5.3.40.0190.10812.03
5.3.30.0060.05111.99
5.3.20.0130.06811.78
5.3.10.0150.07411.73
5.3.00.0120.08911.72
5.2.170.0080.0789.22
5.2.160.0130.0569.22
5.2.150.0100.0459.23
5.2.140.0100.0439.23
5.2.130.0110.0819.18
5.2.120.0120.0659.18
5.2.110.0100.0659.19
5.2.100.0140.0489.19
5.2.90.0030.0599.19
5.2.80.0100.0359.18
5.2.70.0170.0469.18
5.2.60.0060.0379.13
5.2.50.0130.0469.10
5.2.40.0100.0369.07
5.2.30.0080.0309.06
5.2.20.0090.0289.04
5.2.10.0070.0318.95
5.2.00.0080.0308.82
5.1.60.0100.0538.10
5.1.50.0070.0308.09
5.1.40.0510.0898.08
5.1.30.0060.0618.42
5.1.20.0070.0498.45
5.1.10.0060.0288.17
5.1.00.0060.0278.17
5.0.50.0040.0236.66
5.0.40.0070.0206.52
5.0.30.0000.0376.33
5.0.20.0020.0226.29
5.0.10.0050.0196.27
5.0.00.0040.0316.26
4.4.90.0020.0184.77
4.4.80.0020.0164.76
4.4.70.0030.0154.75
4.4.60.0040.0174.75
4.4.50.0040.0144.77
4.4.40.0020.0284.70
4.4.30.0000.0184.76
4.4.20.0030.0154.84
4.4.10.0040.0144.85
4.4.00.0040.0234.76
4.3.110.0010.0174.67
4.3.100.0020.0164.66
4.3.90.0020.0154.64
4.3.80.0030.0244.58
4.3.70.0040.0134.63
4.3.60.0020.0154.63
4.3.50.0040.0134.63
4.3.40.0020.0244.54
4.3.30.0030.0143.30
4.3.20.0030.0153.28
4.3.10.0030.0153.24
4.3.00.0130.0206.93

preferences:
41.06 ms | 401 KiB | 5 Q