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"; $anaaswer = $answer->get()->the()->_answer(); if ($answer instanceof AnswerInterface) { echo $anaaswer . 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.0140.00016.75
8.3.50.0130.00722.05
8.3.40.0040.01118.55
8.3.30.0110.00419.05
8.3.20.0080.00020.34
8.3.10.0080.00021.82
8.3.00.0040.00420.82
8.2.180.0060.01218.20
8.2.170.0140.00022.96
8.2.160.0200.00021.99
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0050.00526.16
8.2.120.0070.00317.80
8.2.110.0040.00719.31
8.2.100.0040.00817.50
8.2.90.0000.00819.17
8.2.80.0030.00517.97
8.2.70.0000.00817.50
8.2.60.0050.00317.80
8.2.50.0000.00818.07
8.2.40.0030.00618.03
8.2.30.0000.00817.99
8.2.20.0050.00217.73
8.2.10.0030.00517.92
8.2.00.0030.00517.73
8.1.280.0110.00725.92
8.1.270.0040.00418.73
8.1.260.0030.00626.35
8.1.250.0080.00028.09
8.1.240.0030.00623.92
8.1.230.0090.00318.85
8.1.220.0000.00717.74
8.1.210.0050.00318.77
8.1.200.0070.00317.23
8.1.190.0080.00017.22
8.1.180.0060.00318.10
8.1.170.0060.00618.71
8.1.160.0040.00422.01
8.1.150.0050.00318.88
8.1.140.0080.00017.30
8.1.130.0000.00817.68
8.1.120.0030.00317.45
8.1.110.0040.00417.28
8.1.100.0040.00417.34
8.1.90.0000.00817.42
8.1.80.0030.00417.43
8.1.70.0000.00817.30
8.1.60.0080.00017.52
8.1.50.0060.00317.46
8.1.40.0000.00817.41
8.1.30.0050.00317.58
8.1.20.0030.00617.45
8.1.10.0040.00417.35
8.1.00.0000.00817.25
8.0.300.0070.00018.77
8.0.290.0000.00816.63
8.0.280.0030.00318.44
8.0.270.0030.00317.24
8.0.260.0000.00617.24
8.0.250.0030.00316.95
8.0.240.0000.00616.92
8.0.230.0030.00616.95
8.0.220.0030.00316.86
8.0.210.0000.00716.91
8.0.200.0030.00317.00
8.0.190.0000.00916.97
8.0.180.0000.00916.91
8.0.170.0050.00316.91
8.0.160.0000.00716.84
8.0.150.0000.00716.88
8.0.140.0040.00416.95
8.0.130.0030.00313.30
8.0.120.0040.00416.87
8.0.110.0070.00016.79
8.0.100.0030.00516.69
8.0.90.0040.00416.88
8.0.80.0100.01016.84
8.0.70.0040.00416.69
8.0.60.0040.00416.79
8.0.50.0000.00816.73
8.0.30.0070.01417.14
8.0.20.0090.01217.40
8.0.10.0050.00217.13
8.0.00.0050.01216.70
7.4.330.0000.00515.08
7.4.320.0060.00016.39
7.4.300.0030.00316.47
7.4.290.0080.00416.45
7.4.280.0030.00716.42
7.4.270.0000.00716.44
7.4.260.0040.00416.45
7.4.250.0000.00716.31
7.4.240.0020.00616.50
7.4.230.0050.00316.61
7.4.220.0040.01416.58
7.4.210.0130.00616.54
7.4.200.0000.00716.53
7.4.160.0120.00916.47
7.4.150.0060.01217.40
7.4.140.0110.00717.86
7.4.130.0090.01416.45
7.4.120.0100.00816.34
7.4.110.0100.01016.40
7.4.100.0170.00316.25
7.4.90.0070.01116.30
7.4.80.0090.01119.39
7.4.70.0030.01416.30
7.4.60.0100.00716.41
7.4.50.0090.00016.31
7.4.40.0160.00016.53
7.4.30.0060.01316.43
7.4.00.0030.01015.02
7.3.330.0000.00613.06
7.3.320.0060.00013.16
7.3.310.0000.00716.13
7.3.300.0000.00716.29
7.3.290.0060.00016.09
7.3.280.0100.00816.24
7.3.270.0120.00817.40
7.3.260.0100.00716.24
7.3.250.0070.01216.34
7.3.240.0160.00616.29
7.3.230.0130.00616.52
7.3.210.0070.01016.45
7.3.200.0030.01819.39
7.3.190.0070.01216.33
7.3.180.0090.00616.26
7.3.170.0060.01316.27
7.3.160.0100.01316.22
7.2.330.0110.00616.43
7.2.320.0130.00316.60
7.2.310.0000.01616.51
7.2.300.0120.00816.50
7.2.290.0040.01216.32
7.2.110.0120.00916.36
7.2.60.0000.01416.64
7.2.00.0030.01019.24
7.1.200.0000.00915.56
7.1.70.0030.00516.72
7.1.60.0060.00616.92
7.1.50.0140.00316.53
7.1.00.0100.07022.31
7.0.200.0040.01116.41
7.0.140.0030.04022.10
7.0.60.0030.04319.82
7.0.50.0030.04017.69
7.0.40.0030.07720.18
7.0.30.0430.07320.09
7.0.20.0330.06720.19
7.0.10.0030.05320.15
7.0.00.0230.07320.25
5.6.280.0070.07020.83
5.6.210.0130.06320.73
5.6.200.0100.03718.28
5.6.190.0030.08320.46
5.6.180.0300.06020.47
5.6.170.0270.09020.56
5.6.160.0200.05720.54
5.6.150.0070.08018.15
5.6.140.0000.07318.29
5.6.130.0130.07718.27
5.6.120.0000.05321.03
5.6.110.0070.08320.99
5.6.100.0070.08720.99
5.6.90.0030.08321.11
5.6.80.0000.04020.54
5.5.350.0230.07720.49
5.5.340.0030.07718.08
5.5.330.0030.05320.40
5.5.320.0370.07020.22
5.5.310.0230.04320.40
5.5.300.0130.07317.99
5.5.290.0100.07017.91
5.5.280.0070.06320.79
5.5.270.0000.06020.87
5.5.260.0130.07720.66
5.5.250.0070.07320.77
5.5.240.0030.08020.30
5.4.450.0800.07319.61
5.4.440.0770.07019.38
5.4.430.0100.06019.46
5.4.420.0130.05019.42
5.4.410.0230.04719.11
5.4.400.0230.05718.81
5.4.390.0270.06018.81
5.4.380.0230.05718.53
5.4.370.0370.04718.80
5.4.360.0370.06718.81
5.4.350.0330.05718.48
5.4.340.0330.04718.61
5.4.320.0370.05018.59
5.4.310.0270.05718.57
5.4.300.0300.06018.75
5.4.290.0330.07018.84
5.4.280.0300.06018.84
5.4.270.0230.05718.60
5.4.260.0200.05718.73
5.4.250.0330.04318.61
5.4.240.0270.05318.56
5.4.230.0200.05318.74
5.4.220.0270.05018.52
5.4.210.0300.05018.50
5.4.200.0270.05016.59
5.4.190.0230.05318.56
5.4.180.0270.05318.82
5.4.170.0270.06718.77
5.4.160.0300.05018.78
5.4.150.0200.06318.51
5.4.140.0300.05716.46
5.4.130.0300.04316.22
5.4.120.0270.04716.28
5.4.110.0270.04716.37
5.4.100.0300.04716.30
5.4.90.0230.05316.33
5.4.80.0200.05316.22
5.4.70.0270.05016.27
5.4.60.0300.05016.26
5.4.50.0230.05016.19
5.4.40.0170.06016.23
5.4.30.0230.05316.40
5.4.20.0370.04016.15
5.4.10.0300.04316.27
5.4.00.0270.04715.69
5.3.290.0370.04314.89
5.3.280.0230.05714.74
5.3.270.0270.05714.82
5.3.260.0430.04014.59
5.3.250.0300.05314.83
5.3.240.0300.05714.71
5.3.230.0400.06314.63
5.3.220.0330.06714.57
5.3.210.0370.07014.62
5.3.200.0300.04714.74
5.3.190.0230.06714.59
5.3.180.0330.04314.55
5.3.170.0300.04314.70
5.3.160.0370.04014.63
5.3.150.0230.05014.62
5.3.140.0300.04714.66
5.3.130.0300.05714.73
5.3.120.0300.05714.73
5.3.110.0200.05714.66
5.3.100.0230.05014.21
5.3.90.0200.05714.03
5.3.80.0300.04314.13
5.3.70.0300.04714.19
5.3.60.0170.05714.02
5.3.50.0130.05713.94
5.3.40.0230.05014.04
5.3.30.0200.05013.92
5.3.20.0230.05013.72
5.3.10.0230.05013.77
5.3.00.0230.07013.87
5.2.170.0200.06311.29
5.2.160.0130.04711.20
5.2.150.0200.06311.36
5.2.140.0170.04711.15
5.2.130.0200.04011.09
5.2.120.0230.03711.11
5.2.110.0230.04011.24
5.2.100.0230.03711.32
5.2.90.0270.03711.14
5.2.80.0230.04011.11
5.2.70.0200.04311.14
5.2.60.0130.05011.04
5.2.50.0200.04011.07
5.2.40.0170.04011.02
5.2.30.0170.04011.09
5.2.20.0200.03710.98
5.2.10.0230.03310.98
5.2.00.0170.04010.82
5.1.60.0200.0309.99
5.1.50.0200.03310.20
5.1.40.0200.04710.03
5.1.30.0170.04310.37
5.1.20.0130.04010.49
5.1.10.0170.03710.17
5.1.00.0170.03710.26
5.0.50.0130.0278.57
5.0.40.0130.0278.45
5.0.30.0130.0478.23
5.0.20.0130.0238.25
5.0.10.0100.0278.29
5.0.00.0030.0478.26
4.4.90.0130.0176.21
4.4.80.0100.0176.21
4.4.70.0030.0276.21
4.4.60.0000.0306.21
4.4.50.0100.0206.21
4.4.40.0070.0376.21
4.4.30.0030.0276.21
4.4.20.0100.0236.21
4.4.10.0070.0236.21
4.4.00.0030.0406.21
4.3.110.0070.0236.21
4.3.100.0030.0276.21
4.3.90.0070.0236.21
4.3.80.0170.0236.21
4.3.70.0130.0176.21
4.3.60.0000.0276.21
4.3.50.0070.0236.21
4.3.40.0100.0336.21
4.3.30.0070.0206.21
4.3.20.0070.0206.21
4.3.10.0070.0206.21
4.3.00.0070.0236.97

preferences:
47.8 ms | 401 KiB | 5 Q