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 $output; public function __construct($output = 4) { $this->output = $output; } public function getOutput() { return $this->output; } public function get() { return $this; } public function the() { return $this; } public function answer() { echo $this->getOutput(); } } // start editing here // 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.0170.00318.30
8.3.50.0100.01122.10
8.3.40.0110.00418.83
8.3.30.0030.01219.13
8.3.20.0060.00320.34
8.3.10.0000.00821.92
8.3.00.0000.00822.45
8.2.180.0190.00016.63
8.2.170.0120.00322.96
8.2.160.0070.00720.82
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00419.36
8.2.110.0060.00319.33
8.2.100.0070.00417.91
8.2.90.0040.00419.05
8.2.80.0000.00817.97
8.2.70.0050.00317.63
8.2.60.0000.00818.05
8.2.50.0000.00918.07
8.2.40.0040.00418.22
8.2.30.0040.00417.92
8.2.20.0070.00017.71
8.2.10.0000.00717.61
8.2.00.0040.00417.55
8.1.280.0060.00825.92
8.1.270.0090.00022.03
8.1.260.0000.00726.35
8.1.250.0050.00328.09
8.1.240.0030.00623.90
8.1.230.0090.00320.85
8.1.220.0080.00017.74
8.1.210.0080.00018.77
8.1.200.0030.00717.36
8.1.190.0050.00317.43
8.1.180.0040.00418.10
8.1.170.0000.00818.69
8.1.160.0040.00421.89
8.1.150.0000.00818.70
8.1.140.0050.00217.29
8.1.130.0040.00417.73
8.1.120.0000.00817.32
8.1.110.0030.00617.48
8.1.100.0050.00217.42
8.1.90.0040.00417.30
8.1.80.0040.00417.49
8.1.70.0030.00317.46
8.1.60.0040.00417.57
8.1.50.0040.00417.53
8.1.40.0030.00517.41
8.1.30.0050.00317.55
8.1.20.0030.00517.61
8.1.10.0000.00717.54
8.1.00.0050.00317.55
8.0.300.0000.00718.77
8.0.290.0000.00817.05
8.0.280.0070.00018.42
8.0.270.0000.00717.16
8.0.260.0040.00416.89
8.0.250.0070.00017.06
8.0.240.0040.00417.01
8.0.230.0040.00417.02
8.0.220.0000.00716.96
8.0.210.0040.00417.00
8.0.200.0030.00317.07
8.0.190.0050.00316.89
8.0.180.0000.00816.89
8.0.170.0000.00816.87
8.0.160.0000.00716.82
8.0.150.0000.00716.85
8.0.140.0000.00716.93
8.0.130.0000.00613.35
8.0.120.0050.00316.91
8.0.110.0000.00717.02
8.0.100.0000.00717.01
8.0.90.0040.00416.92
8.0.80.0090.00616.97
8.0.70.0080.00016.95
8.0.60.0080.00016.92
8.0.50.0070.00017.00
8.0.30.0060.01217.15
8.0.20.0080.01117.40
8.0.10.0050.00217.01
8.0.00.0080.01016.77
7.4.330.0050.00015.15
7.4.320.0000.00616.62
7.4.300.0030.00316.63
7.4.290.0000.00716.51
7.4.280.0000.00816.50
7.4.270.0030.00316.61
7.4.260.0000.00816.59
7.4.250.0030.00616.54
7.4.240.0040.00416.59
7.4.230.0000.00616.39
7.4.220.0160.00716.56
7.4.210.0130.00516.52
7.4.200.0040.00316.57
7.4.190.0040.00416.73
7.4.160.0090.00616.58
7.4.150.0070.01017.40
7.4.140.0050.01217.86
7.4.130.0100.00716.39
7.4.120.0100.00616.46
7.4.110.0090.00916.68
7.4.100.0120.00916.55
7.4.90.0100.00716.61
7.4.80.0200.00319.39
7.4.70.0000.01716.65
7.4.60.0110.00516.60
7.4.50.0040.00416.26
7.4.40.0120.00322.77
7.4.30.0090.01016.33
7.4.00.0060.00915.01
7.3.330.0030.00313.25
7.3.320.0000.00513.11
7.3.310.0040.00416.15
7.3.300.0030.00316.22
7.3.290.0080.00616.30
7.3.280.0080.01016.34
7.3.270.0080.00817.40
7.3.260.0150.00816.46
7.3.250.0040.01316.38
7.3.240.0150.00516.28
7.3.230.0100.00616.41
7.3.210.0090.00916.39
7.3.200.0120.01219.39
7.3.190.0100.00716.18
7.3.180.0100.00716.46
7.3.170.0100.00716.46
7.3.160.0140.00416.36
7.3.120.0030.01314.63
7.2.330.0090.00916.79
7.2.320.0100.01016.80
7.2.310.0070.01116.52
7.2.300.0150.00616.68
7.2.290.0000.01616.59
7.1.200.0030.00715.74
7.1.70.0000.00717.16
7.1.60.0000.01617.20
7.1.50.0240.00334.74
7.1.00.0030.07722.57
7.0.200.0070.01116.75
7.0.140.0070.06722.18
7.0.60.0100.07019.98
7.0.50.0070.07017.89
7.0.40.0070.04320.09
7.0.30.0300.07720.26
7.0.20.0300.07720.06
7.0.10.0270.07720.33
7.0.00.0130.08020.18
5.6.280.0070.07020.87
5.6.210.0070.08320.77
5.6.200.0000.06718.20
5.6.190.0130.08320.61
5.6.180.3870.05320.77
5.6.170.0200.03720.45
5.6.160.0170.04720.44
5.6.150.0000.05018.17
5.6.140.0070.06018.25
5.6.130.0130.08018.21
5.6.120.0070.07721.01
5.6.110.0070.06321.05
5.6.100.0070.08021.00
5.6.90.0130.07321.09
5.6.80.0100.05020.29
5.6.70.0370.07020.51
5.5.350.0030.05320.45
5.5.340.0070.08017.98
5.5.330.0030.04320.47
5.5.320.0300.04020.21
5.5.310.0270.05020.30
5.5.300.0070.05317.99
5.5.290.0070.08017.98
5.5.280.0070.07320.81
5.5.270.0030.04320.74
5.5.260.0100.08720.81
5.5.250.0030.07720.80
5.5.240.0000.04320.05
5.4.450.0430.04019.57
5.4.440.0570.04319.27
5.4.430.0400.06019.55
5.4.420.0600.04319.31
5.4.410.0400.03319.28
5.4.400.0170.04318.63
5.4.390.0170.04718.58
5.4.380.0430.06718.74
5.4.370.0100.05718.50
5.4.360.0170.05018.68
5.4.350.0330.03718.75
5.4.340.0230.04318.68
5.4.320.0060.04812.51
5.4.310.0070.05312.50
5.4.300.0100.03912.51
5.4.290.0060.04612.50
5.4.280.0110.03512.41
5.4.270.0100.05018.98
5.4.260.0070.05318.91
5.4.250.0100.05019.06
5.4.240.0100.07718.84
5.4.230.0130.07318.99
5.4.220.0030.05719.08
5.4.210.0030.06718.82
5.4.200.0000.05718.89
5.4.190.0100.05719.13
5.4.180.0070.05318.97
5.4.170.0070.05718.90
5.4.160.0030.06718.91
5.4.150.0100.08319.13
5.4.140.0100.05716.66
5.4.130.0230.04016.71
5.4.120.0270.05016.46
5.4.110.0170.05316.68
5.4.100.0130.04716.74
5.4.90.0070.06016.54
5.4.80.0030.05016.66
5.4.70.0100.05316.75
5.4.60.0030.06316.50
5.4.50.0070.05016.49
5.4.40.0130.04716.44
5.4.30.0130.05716.59
5.4.20.0100.06716.61
5.4.10.0000.05716.62
5.4.00.0130.04715.87
5.3.290.0070.03812.80
5.3.280.0070.05714.80
5.3.270.0100.06314.79
5.3.260.0170.05314.90
5.3.250.0100.04714.79
5.3.240.0070.06314.50
5.3.230.0070.07014.66
5.3.220.0130.05714.76
5.3.210.0170.05014.87
5.3.200.0070.05314.76
5.3.190.0030.05714.80
5.3.180.0070.06714.75
5.3.170.0130.05014.63
5.3.160.0100.05714.88
5.3.150.0100.05714.60
5.3.140.0030.06314.78
5.3.130.0100.05314.75
5.3.120.0000.06014.62
5.3.110.0100.05014.86
5.3.100.0070.07314.23
5.3.90.0070.07013.91
5.3.80.0100.04714.25
5.3.70.0070.05314.23
5.3.60.0130.05013.89
5.3.50.0070.05013.84
5.3.40.0000.06014.17
5.3.30.0100.06014.10
5.3.20.0070.06314.02
5.3.10.0130.06713.72
5.3.00.0130.04313.86
5.2.170.0000.05711.34
5.2.160.0100.03711.38
5.2.150.0130.03711.28
5.2.140.0100.03711.45
5.2.130.0100.05011.12
5.2.120.0070.05011.38
5.2.110.0070.03711.42
5.2.100.0030.06311.38
5.2.90.0100.05311.11
5.2.80.0130.04311.39
5.2.70.0070.04711.37
5.2.60.0100.04011.25
5.2.50.0070.05311.22
5.2.40.0070.04011.19
5.2.30.0000.04711.04
5.2.20.0030.05711.09
5.2.10.0130.03011.09
5.2.00.0130.05710.91
5.1.60.0170.04010.30
5.1.50.0100.03710.23
5.1.40.0100.02710.09
5.1.30.0070.03310.64
5.1.20.0000.04310.64
5.1.10.0070.03310.35
5.1.00.0030.03710.30
5.0.50.0000.0308.77
5.0.40.0030.0278.48
5.0.30.0070.0408.19
5.0.20.0000.0308.41
5.0.10.0100.0308.48
5.0.00.0030.0438.27
4.4.90.0030.0277.54
4.4.80.0070.0237.54
4.4.70.0070.0237.54
4.4.60.0000.0237.54
4.4.50.0070.0177.54
4.4.40.0030.0537.54
4.4.30.0000.0237.54
4.4.20.0000.0277.54
4.4.10.0000.0277.54
4.4.00.0100.0377.54
4.3.110.0070.0277.54
4.3.100.0070.0177.54
4.3.90.0070.0207.54
4.3.80.0030.0337.54
4.3.70.0000.0237.54
4.3.60.0000.0237.54
4.3.50.0070.0307.54
4.3.40.0000.0337.54
4.3.30.0030.0337.54
4.3.20.0030.0207.54
4.3.10.0030.0307.54
4.3.00.0200.01315.59

preferences:
52.16 ms | 401 KiB | 5 Q