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() { return $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.70.0110.00416.58
8.3.60.0110.01118.56
8.3.50.0200.00821.94
8.3.40.0120.00318.88
8.3.30.0110.00419.13
8.3.20.0060.00320.34
8.3.10.0030.00621.84
8.3.00.0040.00422.52
8.2.180.0100.01016.50
8.2.170.0130.00722.96
8.2.160.0130.00320.98
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00017.48
8.2.110.0090.00022.16
8.2.100.0110.00018.16
8.2.90.0000.00817.75
8.2.80.0080.00017.97
8.2.70.0030.00617.80
8.2.60.0060.00317.80
8.2.50.0050.00318.10
8.2.40.0040.00420.55
8.2.30.0030.00617.94
8.2.20.0050.00317.68
8.2.10.0040.00417.69
8.2.00.0000.00717.68
8.1.280.0070.00725.92
8.1.270.0040.00422.06
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0100.00722.47
8.1.230.0000.01120.88
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0030.00617.13
8.1.190.0080.00017.36
8.1.180.0050.00518.10
8.1.170.0030.00618.46
8.1.160.0070.00022.02
8.1.150.0000.00718.64
8.1.140.0000.00717.40
8.1.130.0030.00517.82
8.1.120.0050.00317.50
8.1.110.0080.00317.51
8.1.100.0040.00417.45
8.1.90.0000.00717.41
8.1.80.0000.00817.44
8.1.70.0000.00817.38
8.1.60.0060.00317.47
8.1.50.0000.00817.50
8.1.40.0030.00517.40
8.1.30.0000.00717.57
8.1.20.0050.00317.59
8.1.10.0040.00417.48
8.1.00.0000.00717.40
8.0.300.0040.00419.84
8.0.290.0100.00316.60
8.0.280.0000.00718.45
8.0.270.0000.00717.25
8.0.260.0030.00316.99
8.0.250.0030.00617.08
8.0.240.0030.00317.03
8.0.230.0040.00417.01
8.0.220.0040.00416.96
8.0.210.0030.00316.92
8.0.200.0000.00716.91
8.0.190.0040.00417.08
8.0.180.0070.00017.03
8.0.170.0040.00416.91
8.0.160.0000.00717.05
8.0.150.0040.00416.87
8.0.140.0040.00416.84
8.0.130.0000.00613.42
8.0.120.0000.00816.79
8.0.110.0110.00116.77
8.0.100.0040.00416.91
8.0.90.0040.00416.75
8.0.80.0040.01116.88
8.0.70.0000.00817.02
8.0.60.0040.00416.87
8.0.50.0050.00317.01
8.0.30.0090.01017.15
8.0.20.0090.00917.40
8.0.10.0050.00216.86
8.0.00.0120.00516.93
7.4.330.0000.00515.14
7.4.320.0030.00316.53
7.4.300.0000.00616.61
7.4.290.0030.00316.59
7.4.280.0000.00816.46
7.4.270.0070.00016.56
7.4.260.0030.00316.50
7.4.250.0050.00516.59
7.4.240.0040.00416.56
7.4.230.0000.00716.70
7.4.220.0070.01416.54
7.4.210.0080.00816.53
7.4.200.0000.00716.41
7.4.190.0070.00016.40
7.4.160.0060.00916.54
7.4.150.0130.01017.40
7.4.140.0120.00717.86
7.4.130.0100.00816.54
7.4.120.0130.00716.38
7.4.110.0090.01516.52
7.4.100.0030.01316.49
7.4.90.0090.00916.42
7.4.80.0040.01619.39
7.4.70.0090.00616.50
7.4.60.0070.01016.63
7.4.50.0000.00816.36
7.4.40.0060.00922.77
7.4.30.0140.00816.55
7.4.00.0080.00914.87
7.3.330.0000.00513.30
7.3.320.0030.00313.30
7.3.310.0070.00016.29
7.3.300.0000.00716.29
7.3.290.0090.00616.32
7.3.280.0130.00616.28
7.3.270.0150.00917.40
7.3.260.0110.00616.50
7.3.250.0020.01616.57
7.3.240.0070.01116.27
7.3.230.0100.00716.56
7.3.210.0090.00616.67
7.3.200.0030.01419.39
7.3.190.0100.01016.36
7.3.180.0060.00916.32
7.3.170.0000.01516.39
7.3.160.0030.01516.33
7.3.120.0070.01014.62
7.3.110.0070.00914.78
7.3.100.0080.00514.75
7.3.90.0070.00614.86
7.3.80.0040.00814.75
7.3.70.0070.00714.79
7.3.60.0060.00714.62
7.3.50.0050.00614.71
7.3.40.0060.00714.75
7.3.30.0080.00714.70
7.3.20.0050.00916.65
7.3.10.0080.00516.51
7.3.00.0030.01216.54
7.2.330.0150.00316.80
7.2.320.0070.01716.76
7.2.310.0060.01316.84
7.2.300.0100.00616.73
7.2.290.0140.00316.81
7.2.250.0090.01014.90
7.2.240.0030.01315.00
7.2.230.0090.00715.03
7.2.220.0040.00915.12
7.2.210.0060.01115.02
7.2.200.0070.00815.09
7.2.190.0060.00615.16
7.2.180.0030.01114.96
7.2.170.0080.00515.21
7.2.160.0040.00815.08
7.2.150.0040.00717.05
7.2.140.0080.00017.01
7.2.130.0100.00017.09
7.2.120.0060.01016.88
7.2.110.0030.01317.02
7.2.100.0040.00717.04
7.2.90.0060.00816.62
7.2.80.0060.00616.68
7.2.70.0060.01216.73
7.2.60.0060.01016.93
7.2.50.0070.00717.02
7.2.40.0060.00916.76
7.2.30.0040.01116.98
7.2.20.0070.00316.67
7.2.10.0040.00816.91
7.2.00.0030.00916.90
7.1.330.0040.00915.77
7.1.320.0060.00715.83
7.1.310.0070.00615.87
7.1.300.0040.00815.79
7.1.290.0090.00515.77
7.1.280.0060.00615.75
7.1.270.0060.00715.73
7.1.260.0060.00715.78
7.1.250.0060.00915.95
7.1.100.0040.00818.16
7.1.70.0000.01016.95
7.1.60.0070.01819.82
7.1.50.0070.01717.04
7.1.00.0000.08022.31
7.0.200.0040.00416.52
7.0.140.0070.07022.09
7.0.110.0170.08319.92
7.0.100.0130.04719.92
7.0.90.0100.05320.07
7.0.80.0100.04720.04
7.0.70.0100.03719.84
7.0.60.0130.04020.01
7.0.50.0100.07019.97
7.0.40.0030.08719.76
7.0.30.0030.04019.66
7.0.20.0070.04319.86
7.0.10.0070.05719.70
7.0.00.0030.04019.65
5.6.280.0000.07320.91
5.6.260.0100.08020.73
5.6.250.0030.04020.71
5.6.240.0170.03020.68
5.6.230.0070.07020.64
5.6.220.0100.07720.64
5.6.210.0070.08020.64
5.6.200.0170.06320.60
5.6.190.0030.07720.63
5.6.180.0100.03720.70
5.6.170.0070.04720.69
5.6.160.0100.04720.63
5.6.150.0030.03720.66
5.6.140.0030.03320.62
5.6.130.0000.03720.66
5.6.120.0030.04020.60
5.6.110.0000.04020.66
5.6.100.0000.04020.61
5.6.90.0070.05320.62
5.6.80.0030.06319.86
5.6.70.0000.04319.85
5.6.60.0000.04320.02
5.6.50.0070.04320.01
5.6.40.0000.04320.06
5.6.30.0100.03320.00
5.6.20.0030.04019.92
5.6.10.0070.03719.92
5.6.00.0070.06019.83
5.5.380.0070.03317.60
5.5.370.0030.07317.59
5.5.360.0030.06717.58
5.5.350.0100.03317.65
5.5.340.0130.07017.90
5.5.330.0030.06718.11
5.5.320.0000.07017.93
5.5.310.0030.07317.83
5.5.300.0070.03018.13
5.5.290.0000.05017.93
5.5.280.0070.04317.89
5.5.270.0000.04718.19
5.5.260.0070.07717.92
5.5.250.0000.04017.74
5.5.240.0170.04717.30
5.5.230.0030.03317.50
5.5.220.0070.03317.30
5.5.210.0000.04017.33
5.5.200.0030.06717.41
5.5.190.0130.05717.45
5.5.180.0000.03717.26
5.5.160.0000.03717.17
5.5.150.0000.05317.26
5.5.140.0100.03317.57
5.5.130.0000.04017.42
5.5.120.0030.04017.44
5.5.110.0000.05317.31
5.5.100.0070.03017.20
5.5.90.0030.06317.08
5.5.80.0100.03317.48
5.5.70.0030.03717.37
5.5.60.0030.04017.07
5.5.50.0030.03317.46
5.5.40.0130.02717.33
5.5.30.0100.02717.37
5.5.20.0070.07017.34
5.5.10.0100.03317.33
5.5.00.0000.04317.36
5.4.450.0030.04019.32
5.4.440.0030.03319.64
5.4.430.0000.03719.49
5.4.420.0030.03319.56
5.4.410.0070.07719.42
5.4.400.0130.04719.18
5.4.390.0070.03719.34
5.4.380.0030.03719.24
5.4.370.0030.04019.18
5.4.360.0030.07019.16
5.4.350.0070.03318.95
5.4.340.0030.04719.31
5.4.320.0000.04019.25
5.4.310.0170.02319.31
5.4.300.0100.06019.14
5.4.290.0070.04019.00
5.4.280.0030.03719.24
5.4.270.0030.06019.18
5.4.260.0000.04019.00
5.4.250.0030.05018.98
5.4.240.0070.06319.14
5.4.230.0000.04718.94
5.4.220.0100.06719.16
5.4.210.0070.06319.33
5.4.200.0030.04319.17
5.4.190.0000.04019.33
5.4.180.0030.04719.00
5.4.170.0070.05019.17
5.4.160.0100.03318.99
5.4.150.0070.03019.00
5.4.140.0030.07316.45
5.4.130.0130.05316.43
5.4.120.0000.04716.52
5.4.110.0070.03716.46
5.4.100.0000.03316.37
5.4.90.0030.04316.46
5.4.80.0100.05716.54
5.4.70.0000.05016.62
5.4.60.0100.06716.57
5.4.50.0030.07316.44
5.4.40.0030.05316.45
5.4.30.0170.03016.39
5.4.20.0100.05716.52
5.4.10.0030.03716.38
5.4.00.0070.04316.04
5.3.290.0030.05714.72
5.3.280.0000.05714.59
5.3.270.0030.04014.61
5.3.260.0170.02314.75
5.3.250.0030.07714.64
5.3.240.0000.07014.63
5.3.230.0130.07014.84
5.3.220.0070.05314.57
5.3.210.0100.07014.44
5.3.200.0070.05014.59
5.3.190.0030.04714.59
5.3.180.0070.04014.70
5.3.170.0030.08314.66
5.3.160.0030.04014.72
5.3.150.0070.06014.70
5.3.140.0030.06014.70
5.3.130.0030.05014.55
5.3.120.0070.06314.41
5.3.110.0000.04014.70
5.3.100.0100.05714.14
5.3.90.0100.07014.07
5.3.80.0000.04013.98
5.3.70.0030.04314.03
5.3.60.0070.03014.16
5.3.50.0000.06013.96
5.3.40.0000.04014.04
5.3.30.0000.04014.00
5.3.20.0030.03713.70
5.3.10.0030.03713.89
5.3.00.0030.03313.78
5.2.170.0000.06712.06
5.2.160.0030.03712.06
5.2.150.0100.02312.06
5.2.140.0030.02712.06
5.2.130.0070.02712.06
5.2.120.0030.02712.06
5.2.110.0030.02712.06
5.2.100.0000.02712.06
5.2.90.0030.02312.06
5.2.80.0030.03312.06
5.2.70.0030.02712.06
5.2.60.0070.02312.06
5.2.50.0070.02712.06
5.2.40.0000.03012.06
5.2.30.0070.05012.06
5.2.20.0100.03012.06
5.2.10.0000.03012.06
5.2.00.0030.02712.06
5.1.60.0030.01712.06
5.1.50.0030.05312.06
5.1.40.0000.02312.06
5.1.30.0030.02312.06
5.1.20.0000.02312.06
5.1.10.0000.02312.06
5.1.00.0000.02712.06
5.0.50.0000.02012.06
5.0.40.0030.01312.06
5.0.30.0000.03012.06
5.0.20.0000.01712.06
5.0.10.0030.01712.06
5.0.00.0000.03312.06
4.4.90.0030.01012.06
4.4.80.0000.01312.06
4.4.70.0070.02712.06
4.4.60.0000.02312.06
4.4.50.0000.02012.06
4.4.40.0030.03012.06
4.4.30.0030.01312.06
4.4.20.0030.01312.06
4.4.10.0000.01712.06
4.4.00.0000.02312.06
4.3.110.0000.01712.06
4.3.100.0030.01012.06
4.3.90.0000.01312.06
4.3.80.0030.02012.06
4.3.70.0030.01712.06
4.3.60.0000.01712.06
4.3.50.0000.01712.06
4.3.40.0000.02312.06
4.3.30.0000.03312.06
4.3.20.0070.01012.06
4.3.10.0000.03312.06
4.3.00.0030.01012.06

preferences:
46.17 ms | 401 KiB | 5 Q