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) { var_dump('yo'); 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.0200.00018.42
8.3.50.0070.00922.01
8.3.40.0030.01418.97
8.3.30.0030.01319.08
8.3.20.0040.00420.21
8.3.10.0080.00022.05
8.3.00.0050.00322.52
8.2.180.0100.00716.75
8.2.170.0090.00622.96
8.2.160.0090.00920.64
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0030.00519.61
8.2.110.0030.00722.11
8.2.100.0070.01017.91
8.2.90.0050.00219.01
8.2.80.0080.00017.97
8.2.70.0050.00317.63
8.2.60.0090.00417.65
8.2.50.0080.00018.07
8.2.40.0060.00318.06
8.2.30.0070.00018.00
8.2.20.0040.00417.78
8.2.10.0000.00717.63
8.2.00.0000.00717.63
8.1.280.0140.00325.92
8.1.270.0000.00922.00
8.1.260.0070.00026.35
8.1.250.0000.00728.09
8.1.240.0060.00324.01
8.1.230.0080.00319.11
8.1.220.0070.00317.74
8.1.210.0000.00718.77
8.1.200.0040.00417.35
8.1.190.0050.00317.40
8.1.180.0060.00318.10
8.1.170.0060.00318.59
8.1.160.0000.00722.06
8.1.150.0080.00018.65
8.1.140.0050.00317.38
8.1.130.0040.00417.83
8.1.120.0000.00817.42
8.1.110.0040.00417.50
8.1.100.0040.00417.32
8.1.90.0030.00517.43
8.1.80.0040.00417.46
8.1.70.0000.00717.46
8.1.60.0060.00317.48
8.1.50.0040.00417.50
8.1.40.0070.00017.51
8.1.30.0040.00417.57
8.1.20.0000.00917.71
8.1.10.0050.00217.50
8.1.00.0030.00617.52
8.0.300.0000.00718.77
8.0.290.0040.00417.28
8.0.280.0000.00718.46
8.0.270.0000.00717.27
8.0.260.0030.00316.96
8.0.250.0030.00316.95
8.0.240.0000.00716.98
8.0.230.0030.00316.96
8.0.220.0030.00316.96
8.0.210.0000.00716.98
8.0.200.0030.00317.06
8.0.190.0040.00417.03
8.0.180.0050.00217.02
8.0.170.0050.00217.03
8.0.160.0040.00416.97
8.0.150.0080.00016.95
8.0.140.0030.00316.95
8.0.130.0000.00613.36
8.0.120.0030.00516.89
8.0.110.0040.00416.87
8.0.100.0050.00317.07
8.0.90.0080.00016.80
8.0.80.0100.00716.94
8.0.70.0030.00516.83
8.0.60.0070.00016.81
8.0.50.0000.00816.94
8.0.30.0090.01016.90
8.0.20.0070.01217.41
8.0.10.0070.00016.93
8.0.00.0050.01216.81
7.4.330.0020.00215.03
7.4.320.0030.00316.58
7.4.300.0030.00316.52
7.4.290.0030.00316.53
7.4.280.0030.00316.56
7.4.270.0040.00416.66
7.4.260.0040.00416.64
7.4.250.0040.00416.41
7.4.240.0030.00516.52
7.4.230.0000.00716.36
7.4.220.0100.01016.64
7.4.210.0070.00816.56
7.4.200.0080.00016.73
7.4.190.0070.00016.76
7.4.160.0100.00716.52
7.4.150.0140.00317.40
7.4.140.0130.01017.86
7.4.130.0050.01416.57
7.4.120.0090.00916.55
7.4.110.0100.00616.59
7.4.100.0140.00416.45
7.4.90.0070.01116.65
7.4.80.0130.01019.39
7.4.70.0200.00016.57
7.4.60.0030.01316.40
7.4.50.0030.00616.22
7.4.40.0140.00422.77
7.4.30.0120.00616.38
7.4.00.0040.01115.24
7.3.330.0030.00313.37
7.3.320.0000.00513.24
7.3.310.0000.00816.40
7.3.300.0070.00016.19
7.3.290.0140.00716.37
7.3.280.0120.00516.33
7.3.270.0090.00817.40
7.3.260.0080.00816.27
7.3.250.0100.00716.33
7.3.240.0100.01116.68
7.3.230.0100.00716.39
7.3.210.0070.01316.36
7.3.200.0090.00919.39
7.3.190.0120.00516.46
7.3.180.0150.00416.48
7.3.170.0140.00516.52
7.3.160.0100.00616.35
7.3.120.0090.00615.01
7.2.330.0120.00616.95
7.2.320.0110.01116.80
7.2.310.0130.01016.85
7.2.300.0030.01616.29
7.2.290.0090.01116.70
7.2.60.0040.00416.92
7.2.00.0000.01019.04
7.1.200.0100.00315.90
7.1.100.0030.01218.14
7.1.70.0000.00717.15
7.1.60.0000.01519.82
7.1.50.0090.01616.79
7.1.00.0070.07322.36
7.0.200.0050.00316.86
7.0.140.0000.07722.01
7.0.60.0030.05019.95
7.0.50.0100.07317.86
7.0.40.0030.04720.27
7.0.30.0370.08320.21
7.0.20.0170.04020.15
7.0.10.0070.07020.19
7.0.00.0030.07720.23
5.6.280.0000.05320.87
5.6.210.0000.05320.48
5.6.200.0030.06718.18
5.6.190.0030.04720.50
5.6.180.0330.04020.77
5.6.170.0170.05020.62
5.6.160.0230.06720.50
5.6.150.0100.07018.15
5.6.140.0000.06318.11
5.6.130.0030.07018.18
5.6.120.0000.04721.13
5.6.110.0030.04021.14
5.6.100.0100.07321.02
5.6.90.0070.04021.03
5.6.80.0030.08020.45
5.5.350.0170.05320.36
5.5.340.0130.03317.98
5.5.330.0130.07720.56
5.5.320.0270.07320.35
5.5.310.0430.06720.29
5.5.300.0070.05018.04
5.5.290.0070.08017.93
5.5.280.0130.04720.88
5.5.270.0030.04020.79
5.5.260.0070.07720.73
5.5.250.0100.06720.59
5.5.240.0070.05020.27
5.4.450.0500.05719.16
5.4.440.0100.06719.48
5.4.430.0230.04719.25
5.4.420.0170.06319.21
5.4.410.0030.07019.41
5.4.400.0100.05318.89
5.4.390.0100.05318.84
5.4.380.0230.06318.50
5.4.370.0200.05318.71
5.4.360.0200.05318.60
5.4.350.0130.06718.59
5.4.340.0230.04718.50
5.4.320.0050.03812.51
5.4.310.0090.03612.50
5.4.300.0070.04312.50
5.4.290.0100.04012.51
5.4.280.0070.04212.40
5.4.270.0170.04718.82
5.4.260.0030.07718.82
5.4.250.0070.05718.86
5.4.240.0130.05018.99
5.4.230.0030.08018.98
5.4.220.0100.08018.99
5.4.210.0070.07718.97
5.4.200.0070.05319.00
5.4.190.0200.05318.76
5.4.180.0100.07019.16
5.4.170.0170.05718.83
5.4.160.0070.07018.90
5.4.150.0100.06019.05
5.4.140.0130.04716.56
5.4.130.0030.05716.66
5.4.120.0170.07316.76
5.4.110.0270.03316.48
5.4.100.0170.06016.48
5.4.90.0070.08316.54
5.4.80.0130.06016.71
5.4.70.0070.05316.46
5.4.60.0070.06016.61
5.4.50.0130.04716.64
5.4.40.0070.05316.51
5.4.30.0070.07016.50
5.4.20.0100.07716.68
5.4.10.0130.07716.38
5.4.00.0300.04016.15
5.3.290.0120.06312.80
5.3.280.0170.07014.81
5.3.270.0070.05714.91
5.3.260.0030.06314.88
5.3.250.0130.04714.73
5.3.240.0030.06314.91
5.3.230.0170.06714.66
5.3.220.0100.07314.85
5.3.210.0170.06714.58
5.3.200.0170.06014.75
5.3.190.0170.05014.87
5.3.180.0100.05714.84
5.3.170.0170.04314.45
5.3.160.0200.05014.80
5.3.150.0170.05714.86
5.3.140.0130.04714.85
5.3.130.0130.05714.61
5.3.120.0100.05314.84
5.3.110.0200.06014.78
5.3.100.0030.06314.33
5.3.90.0130.06714.08
5.3.80.0130.04714.09
5.3.70.0100.06014.29
5.3.60.0030.05714.10
5.3.50.0070.07014.22
5.3.40.0070.07314.18
5.3.30.0100.05313.98
5.3.20.0170.05314.02
5.3.10.0170.06713.78
5.3.00.0130.07713.86
5.2.170.0070.04311.27
5.2.160.0030.05711.04
5.2.150.0030.06711.43
5.2.140.0100.05311.20
5.2.130.0000.05011.43
5.2.120.0030.05011.32
5.2.110.0030.04711.01
5.2.100.0170.04311.33
5.2.90.0200.04711.11
5.2.80.0170.04011.17
5.2.70.0100.05311.15
5.2.60.0130.04711.18
5.2.50.0030.04711.34
5.2.40.0070.05711.30
5.2.30.0100.04310.86
5.2.20.0070.04710.85
5.2.10.0070.05710.87
5.2.00.0130.03710.96
5.1.60.0200.03310.09
5.1.50.0030.05710.22
5.1.40.0130.05010.25
5.1.30.0100.03310.53
5.1.20.0100.03310.48
5.1.10.0030.05710.32
5.1.00.0070.04010.29
5.0.50.0100.0278.88
5.0.40.0100.0238.73
5.0.30.0070.0508.42
5.0.20.0070.0308.51
5.0.10.0170.0338.40
5.0.00.0130.0408.26
4.4.90.0030.0207.48
4.4.80.0130.0177.48
4.4.70.0130.0207.48
4.4.60.0030.0307.48
4.4.50.0070.0237.48
4.4.40.0030.0407.48
4.4.30.0130.0307.48
4.4.20.0070.0207.48
4.4.10.0000.0277.48
4.4.00.0000.0407.48
4.3.110.0000.0337.48
4.3.100.0030.0237.48
4.3.90.0030.0237.48
4.3.80.0070.0337.48
4.3.70.0070.0207.48
4.3.60.0070.0277.48
4.3.50.0000.0237.48
4.3.40.0070.0407.48
4.3.30.0070.0237.48
4.3.20.0030.0307.48
4.3.10.0030.0277.48
4.3.00.0100.0237.28

preferences:
44.34 ms | 401 KiB | 5 Q