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 '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.0070.00718.43
8.3.50.0070.01222.06
8.3.40.0150.00318.89
8.3.30.0100.00719.05
8.3.20.0000.00820.29
8.3.10.0070.00021.95
8.3.00.0080.00022.39
8.2.180.0120.00316.50
8.2.170.0080.00822.96
8.2.160.0100.00720.94
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0030.00617.48
8.2.110.0060.00322.07
8.2.100.0120.00018.16
8.2.90.0040.00419.17
8.2.80.0000.00817.97
8.2.70.0050.00317.50
8.2.60.0070.00717.66
8.2.50.0030.00618.07
8.2.40.0110.00017.90
8.2.30.0040.00418.12
8.2.20.0040.00417.72
8.2.10.0050.00217.73
8.2.00.0050.00317.61
8.1.280.0110.01125.92
8.1.270.0030.00522.14
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.79
8.1.230.0100.00018.97
8.1.220.0130.00017.74
8.1.210.0000.00818.77
8.1.200.0030.00617.24
8.1.190.0000.00817.41
8.1.180.0050.00318.10
8.1.170.0050.00318.65
8.1.160.0040.00422.02
8.1.150.0040.00418.63
8.1.140.0000.00817.51
8.1.130.0040.00417.93
8.1.120.0040.00417.52
8.1.110.0050.00217.51
8.1.100.0030.00317.41
8.1.90.0020.00517.41
8.1.80.0000.00717.46
8.1.70.0000.00717.50
8.1.60.0030.00617.50
8.1.50.0030.00617.53
8.1.40.0050.00317.50
8.1.30.0000.00817.65
8.1.20.0040.00417.61
8.1.10.0020.00517.61
8.1.00.0000.00717.47
8.0.300.0000.00718.77
8.0.290.0030.00317.18
8.0.280.0070.00018.36
8.0.270.0030.00317.21
8.0.260.0060.00016.88
8.0.250.0000.00716.93
8.0.240.0080.00016.99
8.0.230.0000.00716.89
8.0.220.0030.00316.92
8.0.210.0030.00316.87
8.0.200.0000.00716.89
8.0.190.0070.00016.88
8.0.180.0000.00716.87
8.0.170.0050.00216.98
8.0.160.0040.00416.94
8.0.150.0040.00416.87
8.0.140.0080.00016.95
8.0.130.0050.00013.36
8.0.120.0020.00516.87
8.0.110.0000.00716.78
8.0.100.0060.00316.84
8.0.90.0050.00317.02
8.0.80.0080.00816.95
8.0.70.0000.00816.82
8.0.60.0000.00716.93
8.0.50.0040.00416.93
8.0.30.0140.00617.07
8.0.20.0100.00917.40
8.0.10.0040.00417.02
8.0.00.0110.01016.73
7.4.330.0020.00215.20
7.4.320.0060.00316.52
7.4.300.0030.00316.65
7.4.290.0000.00716.52
7.4.280.0000.00816.51
7.4.270.0030.00316.52
7.4.260.0030.00916.41
7.4.250.0030.00616.50
7.4.240.0030.00316.51
7.4.230.0030.00316.34
7.4.220.0160.01016.49
7.4.210.0070.00716.57
7.4.200.0000.00716.41
7.4.190.0050.00316.73
7.4.160.0060.00916.60
7.4.150.0060.01217.40
7.4.140.0130.00817.86
7.4.130.0150.00916.47
7.4.120.0100.01016.59
7.4.110.0040.01816.57
7.4.100.0100.00716.67
7.4.90.0150.00316.62
7.4.80.0070.01719.39
7.4.70.0090.00916.59
7.4.60.0090.00916.48
7.4.50.0040.00416.65
7.4.40.0070.01022.77
7.4.30.0090.00916.50
7.4.00.0080.00814.74
7.3.330.0000.00613.29
7.3.320.0060.00013.23
7.3.310.0070.00016.32
7.3.300.0080.00016.25
7.3.290.0100.00716.27
7.3.280.0090.00616.33
7.3.270.0100.00717.40
7.3.260.0080.00816.32
7.3.250.0060.01116.52
7.3.240.0060.01016.40
7.3.230.0100.00716.39
7.3.210.0130.00316.41
7.3.200.0100.00719.39
7.3.190.0100.00716.36
7.3.180.0100.00616.34
7.3.170.0030.01916.36
7.3.160.0060.00916.45
7.3.120.0060.00615.08
7.3.10.0050.00916.32
7.3.00.0080.00416.56
7.2.330.0030.01516.45
7.2.320.0130.00316.47
7.2.310.0070.01016.71
7.2.300.0060.01016.70
7.2.290.0130.00616.60
7.2.130.0100.01016.80
7.2.120.0100.01016.54
7.2.110.0150.00716.54
7.2.100.0050.00816.77
7.2.90.0030.01016.95
7.2.80.0070.00717.01
7.2.70.0120.00316.98
7.2.60.0100.00516.96
7.2.50.0170.00616.96
7.2.40.0060.00916.77
7.2.30.0150.00016.90
7.2.20.0090.00916.78
7.2.10.0030.00716.85
7.2.00.0030.01018.10
7.1.250.0060.00915.51
7.1.200.0150.00815.90
7.1.100.0030.00618.02
7.1.70.0000.00817.22
7.1.60.0000.01719.82
7.1.50.0100.01316.85
7.1.00.0030.07722.36
7.0.200.0000.00916.95
7.0.140.0100.07021.92
7.0.100.0200.02719.95
7.0.90.0030.04019.98
7.0.80.0070.03319.98
7.0.70.0070.03019.87
7.0.60.0070.04020.02
7.0.50.0100.03020.25
7.0.40.0230.01719.94
7.0.30.0030.03720.08
7.0.20.0000.06720.09
7.0.10.0130.08320.09
7.0.00.0070.06020.17
5.6.280.0030.07321.07
5.6.250.0100.04020.83
5.6.240.0030.04320.70
5.6.230.0070.05020.50
5.6.220.0070.04020.71
5.6.210.0000.04320.68
5.6.200.0070.03321.05
5.6.190.0000.04021.11
5.6.180.0000.03721.04
5.6.170.0070.03321.04
5.6.160.0130.08021.11
5.6.150.0100.08021.18
5.6.140.0070.08021.07
5.6.130.0000.05021.18
5.6.120.0070.04021.05
5.6.110.0070.07721.07
5.6.100.0100.06721.06
5.6.90.0100.04021.04
5.6.80.0130.04720.34
5.6.70.0030.07320.45
5.6.60.0200.06020.29
5.6.50.0130.06720.54
5.6.40.0070.07720.32
5.6.30.0130.06020.54
5.6.20.0100.07320.48
5.6.10.0100.06720.38
5.6.00.0100.07320.49
5.5.380.0070.04020.36
5.5.370.0000.04020.40
5.5.360.0030.04320.42
5.5.350.0000.04320.34
5.5.340.0030.03720.81
5.5.330.0030.04020.84
5.5.320.0030.04320.75
5.5.310.0100.03020.80
5.5.300.0130.07320.91
5.5.290.0070.04020.89
5.5.280.0070.03720.92
5.5.270.0000.08320.83
5.5.260.0070.07020.91
5.5.250.0070.03720.57
5.5.240.0030.06320.28
5.5.230.0030.08320.22
5.5.220.0030.07020.19
5.5.210.0030.08020.11
5.5.200.0070.04019.99
5.5.190.0070.08320.13
5.5.180.0100.03320.21
5.5.160.0000.07720.23
5.5.150.0070.05720.00
5.5.140.0100.08020.15
5.5.130.0030.08020.18
5.5.120.0100.06320.21
5.5.110.0070.07720.14
5.5.100.0000.05020.17
5.5.90.0000.04320.15
5.5.80.0070.04320.09
5.5.70.0130.07020.12
5.5.60.0100.07320.07
5.5.50.0130.04320.07
5.5.40.0070.08020.06
5.5.30.0000.06320.03
5.5.20.0030.08719.99
5.5.10.0030.04720.03
5.5.00.0070.06020.08
5.4.450.0030.03719.46
5.4.440.0070.08319.56
5.4.430.0070.03319.22
5.4.420.0100.08019.50
5.4.410.0100.06319.36
5.4.400.0030.04019.02
5.4.390.0070.07319.06
5.4.380.0000.04019.03
5.4.370.0100.07319.16
5.4.360.0100.06319.14
5.4.350.0170.06319.18
5.4.340.0030.08319.18
5.4.320.0000.08319.14
5.4.310.0070.07019.12
5.4.300.0070.07319.21
5.4.290.0070.05719.14
5.4.280.0030.08019.03
5.4.270.0070.07319.03
5.4.260.0100.04019.12
5.4.250.0030.07319.17
5.4.240.0030.04319.17
5.4.230.0130.07019.13
5.4.220.0100.04319.22
5.4.210.0130.06018.86
5.4.200.0000.08019.20
5.4.190.0070.07018.93
5.4.180.0030.05018.83
5.4.170.0030.06719.08
5.4.160.0170.06719.09
5.4.150.0030.06718.85
5.4.140.0070.05016.47
5.4.130.0100.06016.30
5.4.120.0170.06016.46
5.4.110.0070.05716.38
5.4.100.0030.04716.39
5.4.90.0030.04016.57
5.4.80.0100.05316.54
5.4.70.0000.06016.47
5.4.60.0070.04316.48
5.4.50.0030.05716.33
5.4.40.0130.03316.49
5.4.30.0170.05016.44
5.4.20.0070.04316.33
5.4.10.0000.07716.35
5.4.00.0070.07016.00
5.3.290.0100.07014.66
5.3.280.0100.05014.66
5.3.270.0070.04014.54
5.3.260.0100.04014.61
5.3.250.0070.04714.57
5.3.240.0030.05014.63
5.3.230.0070.05314.70
5.3.220.0030.08014.54
5.3.210.0030.08314.55
5.3.200.0130.03314.53
5.3.190.0070.04014.52
5.3.180.0070.03714.71
5.3.170.0170.05714.54
5.3.160.0030.06714.54
5.3.150.0030.08314.63
5.3.140.0070.03714.70
5.3.130.0070.04014.48
5.3.120.0100.03714.63
5.3.110.0030.07014.65
5.3.100.0130.06714.18
5.3.90.0000.04714.05
5.3.80.0070.04314.17
5.3.70.0030.07714.02
5.3.60.0100.05314.07
5.3.50.0030.03713.96
5.3.40.0030.07013.88
5.3.30.0070.03713.94
5.3.20.0030.05313.61
5.3.10.0070.07013.65
5.3.00.0030.04713.55
5.2.170.0030.04311.24
5.2.160.0000.03711.07
5.2.150.0170.04311.29
5.2.140.0100.05311.26
5.2.130.0100.05711.17
5.2.120.0130.06311.18
5.2.110.0100.04311.25
5.2.100.0070.05011.02
5.2.90.0070.04011.16
5.2.80.0030.05711.22
5.2.70.0070.05310.96
5.2.60.0030.05011.12
5.2.50.0100.05311.04
5.2.40.0030.05311.05
5.2.30.0070.05710.89
5.2.20.0070.05711.04
5.2.10.0000.03710.93
5.2.00.0070.05710.66
5.1.60.0030.02710.10
5.1.50.0070.04310.00
5.1.40.0100.05010.05
5.1.30.0000.05010.39
5.1.20.0000.04310.38
5.1.10.0030.0439.92
5.1.00.0070.04710.10
5.0.50.0000.0508.69
5.0.40.0000.0408.69
5.0.30.0000.0678.69
5.0.20.0070.0178.69
5.0.10.0070.0238.69
5.0.00.0030.0308.69
4.4.90.0030.0238.69
4.4.80.0070.0278.69
4.4.70.0000.0278.69
4.4.60.0000.0378.69
4.4.50.0030.0278.69
4.4.40.0000.0308.69
4.4.30.0030.0338.69
4.4.20.0030.0208.69
4.4.10.0070.0108.69
4.4.00.0000.0378.69
4.3.110.0070.0278.69
4.3.100.0000.0378.69
4.3.90.0030.0338.69
4.3.80.0030.0378.69
4.3.70.0030.0378.69
4.3.60.0070.0278.69
4.3.50.0030.0238.69
4.3.40.0000.0478.69
4.3.30.0030.0208.69
4.3.20.0000.0238.69
4.3.10.0000.0178.69
4.3.00.0070.0278.69

preferences:
41.41 ms | 401 KiB | 5 Q