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(); } class Answer implements AnswerInterface { private $answer = 4; public function get() { return $this; } public function the() { return $this; } public function answer() { return $this->answer; } } $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.70.0150.00318.43
8.3.60.0130.00618.55
8.3.50.0100.00521.21
8.3.40.0150.00018.84
8.3.30.0070.00718.68
8.3.20.0080.00018.73
8.3.10.0000.00821.09
8.3.00.0030.00519.80
8.2.180.0110.00418.30
8.2.170.0100.00722.96
8.2.160.0070.00719.00
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00421.02
8.2.110.0030.00819.39
8.2.100.0130.00317.71
8.2.90.0000.00818.34
8.2.80.0040.00417.97
8.2.70.0040.00417.38
8.2.60.0060.00618.04
8.2.50.0040.00418.07
8.2.40.0080.00018.16
8.2.30.0040.00419.39
8.2.20.0030.00517.65
8.2.10.0030.00517.74
8.2.00.0040.00717.60
8.1.280.0110.00725.92
8.1.270.0040.00423.99
8.1.260.0110.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00622.47
8.1.230.0040.00820.94
8.1.220.0080.00017.74
8.1.210.0050.00318.95
8.1.200.0040.00417.35
8.1.190.0070.00017.41
8.1.180.0050.00318.10
8.1.170.0060.00318.46
8.1.160.0040.00418.89
8.1.150.0030.00618.55
8.1.140.0000.00717.44
8.1.130.0030.00317.75
8.1.120.0040.00417.44
8.1.110.0060.00317.33
8.1.100.0000.00817.52
8.1.90.0000.00717.41
8.1.80.0000.00717.42
8.1.70.0080.00017.44
8.1.60.0060.00317.57
8.1.50.0020.00517.38
8.1.40.0000.00717.35
8.1.30.0060.00317.64
8.1.20.0030.00617.50
8.1.10.0040.00417.59
8.1.00.0040.00417.45
8.0.300.0000.00719.88
8.0.290.0060.00317.18
8.0.280.0040.00418.45
8.0.270.0070.00017.18
8.0.260.0060.00016.80
8.0.250.0070.00016.95
8.0.240.0040.00417.05
8.0.230.0070.00017.02
8.0.220.0030.00316.98
8.0.210.0000.00716.94
8.0.200.0000.00617.08
8.0.190.0070.00016.97
8.0.180.0000.00816.98
8.0.170.0030.00316.97
8.0.160.0070.00016.98
8.0.150.0070.00017.00
8.0.140.0030.00716.79
8.0.130.0030.00313.43
8.0.120.0000.00816.94
8.0.110.0040.00416.83
8.0.100.0070.00016.91
8.0.90.0000.00716.79
8.0.80.0080.00816.95
8.0.70.0000.00716.77
8.0.60.0020.00516.99
8.0.50.0040.00416.84
8.0.30.0080.01017.15
8.0.20.0110.00717.40
8.0.10.0030.00517.02
8.0.00.0080.01416.81
7.4.330.0040.00015.06
7.4.320.0030.00316.48
7.4.300.0000.00716.61
7.4.290.0000.00716.52
7.4.280.0030.00316.35
7.4.270.0070.00016.50
7.4.260.0070.00013.20
7.4.250.0070.00016.61
7.4.240.0000.00816.48
7.4.230.0000.00716.63
7.4.220.0120.00816.65
7.4.210.0050.01116.59
7.4.200.0030.00316.48
7.4.190.0040.00416.37
7.4.160.0080.00816.42
7.4.150.0030.01417.40
7.4.140.0140.00717.86
7.4.130.0090.00916.52
7.4.120.0110.00716.62
7.4.110.0150.01016.49
7.4.100.0140.00316.41
7.4.90.0080.00816.66
7.4.80.0060.01219.39
7.4.70.0090.01216.50
7.4.60.0130.00316.41
7.4.50.0000.00816.37
7.4.40.0060.01022.77
7.4.30.0040.01316.58
7.4.00.0060.01014.85
7.3.330.0020.00213.29
7.3.320.0030.00213.31
7.3.310.0070.00016.35
7.3.300.0040.00216.38
7.3.290.0090.00616.35
7.3.280.0070.01116.33
7.3.270.0110.00617.40
7.3.260.0070.00918.24
7.3.250.0070.01016.49
7.3.240.0040.01616.62
7.3.230.0060.01616.39
7.3.210.0070.01016.38
7.3.200.0040.01319.39
7.3.190.0090.00916.59
7.3.180.0040.01216.56
7.3.170.0030.01216.35
7.3.160.0000.01516.36
7.3.120.0110.00514.92
7.3.110.0110.00714.70
7.3.100.0080.00414.82
7.3.90.0070.00714.73
7.3.80.0080.00414.88
7.3.70.0040.00814.75
7.3.60.0070.00714.68
7.3.50.0050.00614.77
7.3.40.0030.01014.62
7.3.30.0030.01014.88
7.3.20.0070.00316.56
7.3.10.0000.01216.75
7.3.00.0030.01016.63
7.2.330.0120.00816.80
7.2.320.0100.00916.65
7.2.310.0100.01116.33
7.2.300.0030.01616.80
7.2.290.0000.01716.40
7.2.250.0100.01014.94
7.2.240.0090.00915.18
7.2.230.0040.01115.27
7.2.220.0070.00715.00
7.2.210.0100.00714.73
7.2.200.0100.00315.25
7.2.190.0110.00315.07
7.2.180.0060.01014.87
7.2.170.0060.00614.95
7.2.60.0030.01016.87
7.2.00.0090.00319.38
7.1.330.0030.01315.87
7.1.320.0070.00715.95
7.1.310.0040.01116.07
7.1.300.0030.00915.84
7.1.290.0100.00315.82
7.1.280.0030.00915.52
7.1.270.0060.00915.96
7.1.260.0110.00315.91
7.1.200.0120.00315.50
7.1.100.0050.00818.01
7.1.70.0060.00617.03
7.1.60.0130.01019.24
7.1.50.0080.00416.89
7.1.00.0030.03322.45
7.0.200.0000.00916.79
7.0.140.0070.07021.99
7.0.100.0000.04319.99
7.0.90.0000.04720.14
7.0.80.0070.04019.94
7.0.70.0000.04320.02
7.0.60.0070.05019.98
7.0.50.0030.04020.36
7.0.40.0070.04320.14
7.0.30.0070.04320.07
7.0.20.0030.04020.13
7.0.10.0100.05320.04
7.0.00.0130.03020.05
5.6.280.0070.07020.78
5.6.250.0070.05020.64
5.6.240.0000.04720.61
5.6.230.0130.03020.63
5.6.220.0070.03720.67
5.6.210.0030.05720.50
5.6.200.0100.03321.06
5.6.190.0030.04021.05
5.6.180.0100.04320.95
5.6.170.0100.04021.06
5.6.160.0070.03721.06
5.6.150.0130.04321.05
5.6.140.0100.04020.97
5.6.130.0030.04321.17
5.6.120.0070.04021.02
5.6.110.0030.04021.13
5.6.100.0000.04721.11
5.6.90.0000.04320.94
5.6.80.0030.04020.48
5.6.70.0170.02020.43
5.6.60.0130.02320.35
5.6.50.0000.04320.35
5.6.40.0070.03020.53
5.6.30.0070.03020.45
5.6.20.0030.04020.41
5.6.10.0100.03020.39
5.6.00.0030.03720.37
5.5.380.0000.05020.43
5.5.370.0030.04020.40
5.5.360.0030.05020.37
5.5.350.0030.04320.45
5.5.340.0200.06720.80
5.5.330.0030.04720.79
5.5.320.0000.04720.81
5.5.310.0030.06020.89
5.5.300.0000.04720.94
5.5.290.0070.04320.74
5.5.280.0030.04320.82
5.5.270.0030.04320.63
5.5.260.0070.04320.90
5.5.250.0030.04020.73
5.5.240.0030.04020.23
5.5.230.0070.04020.22
5.5.220.0070.03720.03
5.5.210.0030.03320.14
5.5.200.0030.03320.28
5.5.190.0070.03020.27
5.5.180.0070.03320.24
5.5.160.0030.03320.16
5.5.150.0100.06320.23
5.5.140.0070.04020.11
5.5.130.0100.06720.15
5.5.120.0000.08320.24
5.5.110.0000.04020.00
5.5.100.0100.06020.11
5.5.90.0100.05020.15
5.5.80.0070.04020.13
5.5.70.0270.06720.07
5.5.60.0030.05320.07
5.5.50.0130.07320.12
5.5.40.0170.03720.04
5.5.30.0070.08020.07
5.5.20.0070.07719.91
5.5.10.0100.04020.12
5.5.00.0070.06319.95
5.4.450.0070.03719.38
5.4.440.0000.04319.27
5.4.430.0030.04019.37
5.4.420.0070.04019.37
5.4.410.0030.03719.24
5.4.400.0070.03019.21
5.4.390.0030.04019.21
5.4.380.0030.03018.86
5.4.370.0000.03319.04
5.4.360.0130.02019.23
5.4.350.0030.04319.00
5.4.340.0100.02719.18
5.4.320.0100.02719.05
5.4.310.0030.04019.16
5.4.300.0030.07019.03
5.4.290.0100.06019.09
5.4.280.0030.08018.95
5.4.270.0030.07719.12
5.4.260.0030.08018.86
5.4.250.0130.07019.02
5.4.240.0130.07319.20
5.4.230.0100.04319.20
5.4.220.0030.08319.04
5.4.210.0000.08019.12
5.4.200.0030.08719.04
5.4.190.0100.07319.03
5.4.180.0070.07319.21
5.4.170.0030.06019.13
5.4.160.0000.07719.09
5.4.150.0130.06319.14
5.4.140.0070.04016.51
5.4.130.0030.04716.38
5.4.120.0030.07316.47
5.4.110.0070.05716.56
5.4.100.0030.07716.45
5.4.90.0100.07016.50
5.4.80.0100.06016.46
5.4.70.0030.07316.51
5.4.60.0000.04716.36
5.4.50.0070.04316.32
5.4.40.0170.05016.46
5.4.30.0030.05316.25
5.4.20.0100.04316.41
5.4.10.0070.04716.44
5.4.00.0030.05315.87
5.3.290.0030.03314.60
5.3.280.0030.08314.62
5.3.270.0070.07314.71
5.3.260.0070.07314.70
5.3.250.0000.08014.67
5.3.240.0130.05014.60
5.3.230.0070.03714.71
5.3.220.0030.05314.59
5.3.210.0030.04314.56
5.3.200.0030.07714.63
5.3.190.0070.07314.70
5.3.180.0070.07714.59
5.3.170.0070.07014.52
5.3.160.0200.05314.62
5.3.150.0030.06014.56
5.3.140.0030.04014.50
5.3.130.0030.08314.61
5.3.120.0100.06714.56
5.3.110.0070.07014.62
5.3.100.0100.06714.12
5.3.90.0130.06014.02
5.3.80.0070.04014.16
5.3.70.0070.07313.95
5.3.60.0130.05714.04
5.3.50.0030.07713.93
5.3.40.0030.06714.05
5.3.30.0030.04013.94
5.3.20.0070.06013.61
5.3.10.0030.04013.72
5.3.00.0000.07313.65
5.2.170.0000.03711.01
5.2.160.0000.06311.21
5.2.150.0030.06011.04
5.2.140.0030.05311.20
5.2.130.0130.05010.99
5.2.120.0100.05711.16
5.2.110.0030.06711.03
5.2.100.0000.04711.21
5.2.90.0070.05011.17
5.2.80.0000.06311.20
5.2.70.0100.04011.02
5.2.60.0000.07011.09
5.2.50.0030.05010.93
5.2.40.0070.03311.11
5.2.30.0100.05711.04
5.2.20.0030.05010.97
5.2.10.0000.03310.95
5.2.00.0030.04310.86
5.1.60.0000.06010.10
5.1.50.0030.02310.10
5.1.40.0070.0439.84
5.1.30.0030.04010.48
5.1.20.0000.02710.48
5.1.10.0030.0509.91
5.1.00.0030.02310.18
5.0.50.0030.0438.55
5.0.40.0070.0408.49
5.0.30.0070.0478.20
5.0.20.0070.0438.20
5.0.10.0030.0378.26
5.0.00.0030.0478.23
4.4.90.0000.0178.20
4.4.80.0000.0178.20
4.4.70.0000.0338.20
4.4.60.0000.0338.20
4.4.50.0030.0208.20
4.4.40.0030.0508.20
4.4.30.0070.0338.20
4.4.20.0030.0208.20
4.4.10.0000.0338.20
4.4.00.0000.0478.20
4.3.110.0000.0208.20
4.3.100.0030.0178.20
4.3.90.0000.0238.20
4.3.80.0000.0238.20
4.3.70.0030.0238.20
4.3.60.0000.0138.20
4.3.50.0030.0208.20
4.3.40.0030.0478.20
4.3.30.0000.0378.20
4.3.20.0000.0178.20
4.3.10.0000.0278.20
4.3.00.0030.0208.20

preferences:
53.46 ms | 401 KiB | 5 Q