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 $this->get(); } } // 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.1150.02695.64
8.3.50.1110.03996.40
8.3.40.0560.01047.84
8.3.30.0400.00748.27
8.3.20.0180.00749.38
8.3.10.0190.00451.02
8.3.00.0090.00947.16
8.2.180.0070.01825.50
8.2.170.0190.00627.70
8.2.160.0170.00729.11
8.2.150.0130.00028.15
8.2.140.0100.00330.13
8.2.130.0120.00330.20
8.2.120.0030.00930.27
8.2.110.0130.00328.84
8.2.100.0200.00026.47
8.2.90.0120.00027.97
8.2.80.0070.00726.90
8.2.70.0100.00326.50
8.2.60.0100.00726.90
8.2.50.0130.00326.50
8.2.40.0140.00027.94
8.2.30.0060.00627.11
8.2.20.0040.00726.59
8.2.10.0070.00426.97
8.2.00.0100.00326.55
8.1.280.0270.00326.06
8.1.270.0230.00331.82
8.1.260.0070.00727.80
8.1.250.0120.00031.83
8.1.240.0090.00631.96
8.1.230.0140.00729.98
8.1.220.0060.00626.54
8.1.210.0060.00626.36
8.1.200.0090.00626.13
8.1.190.0060.00626.41
8.1.180.0130.00026.35
8.1.170.0100.00327.38
8.1.160.0050.00531.09
8.1.150.0090.00327.70
8.1.140.0060.00626.57
8.1.130.0070.00326.89
8.1.120.0070.00326.55
8.1.110.0160.00026.54
8.1.100.0120.00026.57
8.1.90.0040.00826.47
8.1.80.0030.00726.55
8.1.70.0100.00026.50
8.1.60.0090.00326.56
8.1.50.0040.00826.57
8.1.40.0090.00326.47
8.1.30.0040.00726.66
8.1.20.0030.00926.63
8.1.10.0040.00726.63
8.1.00.0060.00626.65
8.0.300.0060.00626.84
8.0.290.0100.00325.91
8.0.280.0070.00327.29
8.0.270.0030.00726.10
8.0.260.0060.00326.05
8.0.250.0120.00025.89
8.0.240.0090.00325.75
8.0.230.0030.00725.72
8.0.220.0070.00325.63
8.0.210.0120.00025.86
8.0.200.0070.00425.79
8.0.190.0110.00025.73
8.0.180.0090.00625.72
8.0.170.0040.00825.71
8.0.160.0040.00725.77
8.0.150.0100.00025.65
8.0.140.0060.00625.74
8.0.130.0130.00022.28
8.0.120.0110.00025.76
8.0.110.0050.00525.62
8.0.100.0080.00325.85
8.0.90.0100.00025.61
8.0.80.0160.01325.78
8.0.70.0040.00725.68
8.0.60.0070.00725.78
8.0.50.0070.00325.61
8.0.30.0170.01725.89
8.0.20.0200.00925.86
8.0.10.0060.00625.86
8.0.00.0190.01025.62
7.4.330.0030.00315.00
7.4.320.0040.00416.58
7.4.300.0060.00016.59
7.4.290.0030.00316.65
7.4.280.0000.00716.51
7.4.270.0040.00416.52
7.4.260.0030.00516.51
7.4.250.0080.00016.53
7.4.240.0030.00416.47
7.4.230.0040.00416.59
7.4.220.0090.00916.57
7.4.210.0090.00916.42
7.4.200.0040.00416.40
7.4.190.0000.00716.46
7.4.160.0070.00716.41
7.4.150.0090.01017.40
7.4.140.0090.00917.86
7.4.130.0090.01116.60
7.4.120.0110.00816.65
7.4.110.0120.00616.48
7.4.100.0030.01516.64
7.4.90.0140.00416.43
7.4.80.0160.00919.39
7.4.70.0060.01616.67
7.4.60.0100.01016.62
7.4.50.0040.00016.38
7.4.40.0100.00722.77
7.4.30.0100.00716.45
7.4.10.0040.01214.75
7.4.00.0060.01014.81
7.3.330.0050.00013.22
7.3.320.0020.00213.16
7.3.310.0000.00816.40
7.3.300.0030.00616.31
7.3.290.0050.01116.30
7.3.280.0110.00616.29
7.3.270.0090.00917.40
7.3.260.0140.00916.52
7.3.250.0130.00516.49
7.3.240.0070.01016.41
7.3.230.0110.00716.40
7.3.210.0100.01316.46
7.3.200.0110.00919.39
7.3.190.0040.01616.39
7.3.180.0080.00716.35
7.3.170.0090.00916.48
7.3.160.0060.00916.40
7.3.130.0100.01014.66
7.3.120.0040.01115.04
7.3.110.0060.01014.67
7.3.100.0070.00914.89
7.3.90.0020.01214.73
7.3.80.0050.01014.88
7.3.70.0070.00614.93
7.3.60.0030.00914.89
7.3.50.0100.00514.75
7.3.40.0060.00814.75
7.3.30.0050.01014.74
7.3.20.0000.01316.57
7.3.10.0060.00816.54
7.3.00.0090.00516.66
7.2.330.0090.00916.80
7.2.320.0070.01016.76
7.2.310.0030.01716.45
7.2.300.0070.01016.75
7.2.290.0140.00316.68
7.2.260.0090.00915.26
7.2.250.0050.01415.13
7.2.240.0070.00915.10
7.2.230.0040.01014.90
7.2.220.0080.00814.94
7.2.210.0050.00715.04
7.2.200.0050.00915.04
7.2.190.0070.00615.06
7.2.180.0080.00815.18
7.2.170.0110.00315.01
7.2.160.0030.01114.88
7.2.150.0070.01016.88
7.2.140.0060.00616.84
7.2.130.0080.00516.83
7.2.120.0060.00616.88
7.2.110.0040.01116.90
7.2.100.0040.00816.78
7.2.90.0050.00616.93
7.2.80.0060.00817.03
7.2.70.0020.01116.90
7.2.60.0050.00916.97
7.2.50.0040.01016.87
7.2.40.0050.00917.04
7.2.30.0050.00716.88
7.2.20.0030.01016.96
7.2.10.0060.00616.98
7.2.00.0090.00517.48
7.1.330.0050.01315.70
7.1.320.0050.00715.91
7.1.310.0060.00615.66
7.1.300.0020.00915.78
7.1.290.0050.01015.65
7.1.280.0060.00815.86
7.1.270.0040.00715.53
7.1.260.0000.01315.74
7.1.250.0070.00615.70
7.1.240.0080.00515.76
7.1.230.0070.00715.89
7.1.220.0030.01015.88
7.1.210.0060.00715.54
7.1.200.0050.00915.74
7.1.190.0080.00415.81
7.1.180.0030.01015.67
7.1.170.0030.01015.65
7.1.160.0070.00715.49
7.1.150.0040.00715.79
7.1.140.0030.00715.83
7.1.130.0130.00315.64
7.1.120.0090.00215.69
7.1.110.0070.00815.66
7.1.100.0070.00716.55
7.1.90.0020.01015.64
7.1.80.0080.00415.73
7.1.70.0060.00816.30
7.1.60.0050.00917.02
7.1.50.0030.01516.14
7.1.40.0030.00915.45
7.1.30.0060.00215.82
7.1.20.0040.00915.55
7.1.10.0070.00515.87
7.1.00.0050.03117.89
7.0.330.0050.00515.48
7.0.320.0110.00315.39
7.0.310.0030.01115.31
7.0.300.0060.00915.28
7.0.290.0050.00815.32
7.0.280.0080.00415.26
7.0.270.0080.00615.42
7.0.260.0060.00615.50
7.0.250.0050.01115.43
7.0.240.0040.00915.37
7.0.230.0050.00715.24
7.0.220.0050.00815.39
7.0.210.0030.00715.55
7.0.200.0040.00915.88
7.0.190.0060.00815.48
7.0.180.0020.01015.38
7.0.170.0030.01015.32
7.0.160.0030.00815.39
7.0.150.0050.01015.37
7.0.140.0060.02817.53
7.0.130.0080.00515.49
7.0.120.0050.00715.29
7.0.110.0180.03216.77
7.0.100.0240.03016.86
7.0.90.0160.03416.92
7.0.80.0200.03216.94
7.0.70.0090.02116.87
7.0.60.0050.02817.07
7.0.50.0070.02717.07
7.0.40.0040.03015.47
7.0.30.0070.02815.52
7.0.20.0080.02715.55
7.0.10.0050.02515.63
7.0.00.0060.02115.50
5.6.400.0080.00614.29
5.6.390.0060.00814.33
5.6.380.0020.01014.46
5.6.370.0050.01114.50
5.6.360.0050.01114.54
5.6.350.0050.01114.30
5.6.340.0080.00514.56
5.6.330.0050.00914.31
5.6.320.0030.00814.59
5.6.310.0070.00614.52
5.6.300.0090.00714.26
5.6.290.0100.00514.24
5.6.280.0080.02716.72
5.6.270.0080.00714.37
5.6.260.0070.02816.52
5.6.250.0060.02216.36
5.6.240.0040.03216.40
5.6.230.0030.03216.53
5.6.220.0050.03116.37
5.6.210.0040.03516.36
5.6.200.0030.01916.61
5.6.190.0040.01616.38
5.6.180.0070.03316.54
5.6.170.0050.02916.41
5.6.160.0050.02016.42
5.6.150.0060.03216.53
5.6.140.0090.02416.47
5.6.130.0070.02516.31
5.6.120.0050.03116.44
5.6.110.0030.03616.42
5.6.100.0080.03016.43
5.6.90.0030.02216.47
5.6.80.0090.02716.25
5.6.70.0070.01516.23
5.6.60.0000.02716.17
5.6.50.0060.03016.14
5.6.40.0030.03316.16
5.6.30.0030.02816.09
5.6.20.0070.02016.11
5.6.10.0060.02016.24
5.6.00.0040.02216.22
5.5.380.0050.02715.39
5.5.370.0070.03015.38
5.5.360.0110.03015.33
5.5.350.0100.03115.42
5.5.340.0040.02315.66
5.5.330.0030.03515.46
5.5.320.0080.02215.53
5.5.310.0050.02515.55
5.5.300.0040.03715.47
5.5.290.0090.02915.48
5.5.280.0080.02315.58
5.5.270.0030.02815.48
5.5.260.0070.03215.47
5.5.250.0080.01315.48
5.5.240.0060.02115.25
5.5.230.0050.02915.34
5.5.220.0100.01615.27
5.5.210.0070.02715.30
5.5.200.0050.02215.20
5.5.190.0070.03015.40
5.5.180.0060.02215.28
5.5.170.0030.01214.14
5.5.160.0020.02115.36
5.5.150.0060.01715.28
5.5.140.0090.03215.16
5.5.130.0100.02715.35
5.5.120.0050.02215.40
5.5.110.0050.01615.23
5.5.100.0060.02415.09
5.5.90.0080.02315.27
5.5.80.0070.01515.07
5.5.70.0060.01915.20
5.5.60.0090.02815.19
5.5.50.0060.01715.20
5.5.40.0070.02915.21
5.5.30.0110.02415.31
5.5.20.0070.01815.11
5.5.10.0050.02115.32
5.5.00.0080.02715.20
5.4.450.0050.02514.05
5.4.440.0050.03214.18
5.4.430.0010.03214.23
5.4.420.0040.01714.21
5.4.410.0040.01514.05
5.4.400.0020.03113.96
5.4.390.0070.02914.10
5.4.380.0030.02914.13
5.4.370.0060.02814.05
5.4.360.0060.01714.01
5.4.350.0090.02514.08
5.4.340.0060.01614.10
5.4.330.0020.00611.54
5.4.320.0050.01613.88
5.4.310.0010.02214.13
5.4.300.0080.01914.13
5.4.290.0080.02014.09
5.4.280.0030.02313.94
5.4.270.0040.01714.04
5.4.260.0050.01314.08
5.4.250.0030.02014.08
5.4.240.0020.02313.94
5.4.230.0010.02014.18
5.4.220.0000.02314.09
5.4.210.0060.02314.07
5.4.200.0010.01914.06
5.4.190.0040.02614.02
5.4.180.0030.03014.14
5.4.170.0030.02013.97
5.4.160.0030.01714.05
5.4.150.0000.02713.99
5.4.140.0050.02913.06
5.4.130.0090.01113.31
5.4.120.0020.01813.07
5.4.110.0030.02913.19
5.4.100.0020.01713.20
5.4.90.0050.02313.20
5.4.80.0010.03213.21
5.4.70.0020.02313.22
5.4.60.0020.02113.20
5.4.50.0060.01513.12
5.4.40.0060.01713.15
5.4.30.0020.01613.04
5.4.20.0060.01313.17
5.4.10.0050.01513.15
5.4.00.0090.01112.97
5.3.290.0060.02412.46
5.3.280.0020.01712.43
5.3.270.0030.01812.42
5.3.260.0050.02712.43
5.3.250.0080.02112.43
5.3.240.0050.03212.43
5.3.230.0060.02212.43
5.3.220.0040.01812.41
5.3.210.0020.02212.36
5.3.200.0050.02812.41
5.3.190.0030.02612.46
5.3.180.0060.01812.43
5.3.170.0020.01412.41
5.3.160.0070.02112.42
5.3.150.0020.01712.46
5.3.140.0040.01812.41
5.3.130.0040.02212.43
5.3.120.0050.01512.36
5.3.110.0060.01712.41
5.3.100.0050.01512.24
5.3.90.0050.01612.23
5.3.80.0080.01812.22
5.3.70.0040.01612.27
5.3.60.0010.01712.27
5.3.50.0030.01412.23
5.3.40.0040.01412.23
5.3.30.0060.02112.20
5.3.20.0030.01412.07
5.3.10.0000.01612.18
5.3.00.0050.01512.12
5.2.170.0070.02712.16
5.2.160.0100.02712.16
5.2.150.0030.02312.16
5.2.140.0030.02712.16
5.2.130.0100.03312.16
5.2.120.0000.03012.16
5.2.110.0000.02712.16
5.2.100.0030.03012.16
5.2.90.0030.03312.16
5.2.80.0000.02712.16
5.2.70.0000.03012.16
5.2.60.0000.03012.16
5.2.50.0070.02712.16
5.2.40.0070.02312.16
5.2.30.0030.03712.16
5.2.20.0000.03012.16
5.2.10.0000.03012.16
5.2.00.0000.02712.16
5.1.60.0070.02012.16
5.1.50.0000.02712.16
5.1.40.0030.02312.16
5.1.30.0030.02712.16
5.1.20.0000.02712.16
5.1.10.0000.03012.16
5.1.00.0000.02712.16
5.0.50.0030.01712.16
5.0.40.0000.02012.16
5.0.30.0000.03012.16
5.0.20.0000.01712.16
5.0.10.0000.02012.16
5.0.00.0030.03312.16
4.4.90.0030.01312.16
4.4.80.0000.02312.16
4.4.70.0030.01312.16
4.4.60.0000.01312.16
4.4.50.0000.01712.16
4.4.40.0030.02312.16
4.4.30.0030.01312.16
4.4.20.0030.01312.16
4.4.10.0070.01012.16
4.4.00.0030.01712.16
4.3.110.0000.01712.16
4.3.100.0000.01312.16
4.3.90.0000.01312.16
4.3.80.0000.02312.16
4.3.70.0070.01012.16
4.3.60.0000.01312.16
4.3.50.0000.01312.16
4.3.40.0000.02012.16
4.3.30.0000.01712.16
4.3.20.0000.01712.16
4.3.10.0000.01312.16
4.3.00.0030.01312.16

preferences:
44.34 ms | 401 KiB | 5 Q