3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Challenge 2: Implement AnswerInterface and get Question to echo "4". */ interface AnswerInterface { public function get(); public function the(); public function answer(); } 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; } } } // start editing here class Answer implements AnswerInterface { public function get() { return $this; } public function the(){ return $this; } public function answer(){ 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.0110.00818.31
8.3.50.0140.00422.01
8.3.40.0090.00618.84
8.3.30.0100.01319.09
8.3.20.0040.00420.30
8.3.10.0040.00422.10
8.3.00.0040.00422.46
8.2.180.0080.00616.63
8.2.170.0040.01122.96
8.2.160.0070.01020.83
8.2.150.0030.00624.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00017.63
8.2.110.0060.00322.10
8.2.100.0070.00417.91
8.2.90.0000.00819.05
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0040.00417.93
8.2.50.0080.00018.07
8.2.40.0000.00818.03
8.2.30.0050.00317.98
8.2.20.0070.00017.56
8.2.10.0000.00817.54
8.2.00.0070.00017.69
8.1.280.0140.00725.92
8.1.270.0040.00422.14
8.1.260.0040.00426.35
8.1.250.0030.00628.09
8.1.240.0100.00023.69
8.1.230.0030.00718.96
8.1.220.0000.00717.79
8.1.210.0080.00018.77
8.1.200.0030.00617.25
8.1.190.0030.00617.53
8.1.180.0000.00818.10
8.1.170.0040.00418.50
8.1.160.0030.00322.00
8.1.150.0030.00618.68
8.1.140.0040.00417.36
8.1.130.0000.00717.79
8.1.120.0000.00717.46
8.1.110.0050.00317.50
8.1.100.0040.00417.43
8.1.90.0030.00517.38
8.1.80.0040.00417.45
8.1.70.0070.00017.36
8.1.60.0090.00317.59
8.1.50.0000.00817.41
8.1.40.0040.00417.50
8.1.30.0040.00417.53
8.1.20.0000.00917.55
8.1.10.0080.00017.57
8.1.00.0040.00417.52
8.0.300.0050.00218.77
8.0.290.0040.00417.05
8.0.280.0030.00318.50
8.0.270.0040.00417.32
8.0.260.0000.00716.84
8.0.250.0070.00017.05
8.0.240.0000.00716.97
8.0.230.0070.00017.05
8.0.220.0070.00017.00
8.0.210.0040.00416.91
8.0.200.0040.00417.01
8.0.190.0000.00716.96
8.0.180.0040.00716.89
8.0.170.0000.00716.88
8.0.160.0040.00416.91
8.0.150.0040.00416.95
8.0.140.0000.00716.87
8.0.130.0000.00513.39
8.0.120.0050.00216.93
8.0.110.0070.00016.86
8.0.100.0040.00416.73
8.0.90.0050.00316.74
8.0.80.0070.01017.00
8.0.70.0040.00416.84
8.0.60.0000.00716.84
8.0.50.0000.00817.02
8.0.30.0100.01317.18
8.0.20.0040.01517.40
8.0.10.0000.00717.10
8.0.00.0110.00716.95
7.4.330.0030.00315.00
7.4.320.0050.00316.56
7.4.300.0030.00316.52
7.4.290.0070.00016.43
7.4.280.0040.00416.39
7.4.270.0070.00016.58
7.4.260.0060.00316.48
7.4.250.0000.00716.46
7.4.240.0060.00116.57
7.4.230.0020.00516.48
7.4.220.0110.00716.68
7.4.210.0080.00716.57
7.4.200.0040.00416.26
7.4.190.0030.00316.77
7.4.160.0090.00616.46
7.4.150.0120.00817.40
7.4.140.0060.01117.86
7.4.130.0180.00116.60
7.4.120.0120.00816.73
7.4.110.0060.01016.48
7.4.100.0080.00816.56
7.4.90.0030.02016.48
7.4.80.0030.01319.39
7.4.70.0080.01216.34
7.4.60.0080.00816.63
7.4.50.0040.00416.64
7.4.40.0050.00822.77
7.4.30.0060.00916.63
7.4.00.0120.00514.92
7.3.330.0030.00313.43
7.3.320.0020.00213.36
7.3.310.0000.00816.46
7.3.300.0000.00716.23
7.3.290.0090.00616.40
7.3.280.0070.01216.33
7.3.270.0190.00417.40
7.3.260.0090.00916.42
7.3.250.0090.00916.47
7.3.240.0090.00916.50
7.3.230.0070.01016.40
7.3.210.0120.00616.54
7.3.200.0130.00316.52
7.3.190.0090.01316.32
7.3.180.0130.00716.61
7.3.170.0130.00716.27
7.3.160.0080.00816.43
7.3.120.0050.01214.70
7.3.110.0080.00714.89
7.3.100.0060.00914.63
7.3.90.0040.01014.82
7.3.80.0090.00615.00
7.3.70.0060.00814.84
7.3.60.0030.01214.61
7.3.50.0060.00514.71
7.3.40.0020.01214.92
7.3.30.0060.00514.85
7.3.20.0050.00916.44
7.3.10.0030.01016.72
7.3.00.0050.01116.63
7.2.330.0030.01516.74
7.2.320.0060.01316.45
7.2.310.0100.01516.38
7.2.300.0120.00916.69
7.2.290.0100.00716.48
7.2.250.0100.00715.03
7.2.240.0090.01115.04
7.2.230.0070.01015.05
7.2.220.0040.00714.95
7.2.210.0090.00414.65
7.2.200.0020.01114.97
7.2.190.0060.00315.06
7.2.180.0090.00514.96
7.2.170.0030.01015.05
7.2.60.0100.00316.95
7.2.00.0250.00019.24
7.1.330.0050.01015.57
7.1.320.0030.00515.74
7.1.310.0030.01115.49
7.1.300.0040.00715.87
7.1.290.0040.01015.81
7.1.280.0050.00515.79
7.1.270.0020.00915.86
7.1.260.0060.00715.56
7.1.200.0030.01215.48
7.1.100.0070.01418.00
7.1.70.0050.00917.22
7.1.60.0090.00617.23
7.1.50.0080.00816.57
7.1.40.0040.00716.70
7.1.30.0060.00916.52
7.1.20.0000.01416.62
7.1.10.0040.00716.45
7.1.00.0000.00916.41
7.0.200.0070.01116.82
7.0.190.0060.00616.39
7.0.180.0100.00316.40
7.0.170.0050.00516.36
7.0.160.0100.00316.06
7.0.150.0030.01316.17
7.0.140.0000.01816.20
7.0.130.0080.00416.48
7.0.120.0080.00416.16
7.0.110.0070.00716.19
7.0.100.0020.01216.18
7.0.90.0000.01016.55
7.0.80.0000.01116.40
7.0.70.0000.01116.35
7.0.60.0040.00416.07
7.0.50.0020.00716.46
7.0.40.0000.01115.18
7.0.30.0030.01015.18
7.0.20.0030.00715.18
7.0.10.0030.00915.18
7.0.00.0030.00615.18
5.6.300.0000.05120.71
5.6.290.0070.04420.85
5.6.280.0030.04520.74
5.6.270.0150.03820.80
5.6.260.0070.04820.70
5.6.250.0070.03920.76
5.6.240.0160.03220.89
5.6.230.0030.04320.85
5.6.220.0060.04220.89
5.6.210.0030.04521.04
5.6.200.0060.04020.90
5.6.190.0070.04320.86
5.6.180.0100.06220.97
5.6.170.0000.09120.70
5.6.160.0090.04120.90
5.6.150.0030.04620.95
5.6.140.0000.04920.67
5.6.130.0030.06520.85
5.6.120.0030.04220.86
5.6.110.0100.07020.71
5.6.100.0030.04320.73
5.6.90.0100.04120.81
5.6.80.0070.05220.13
5.6.70.0070.03720.25
5.6.60.0100.05820.08
5.6.50.0000.07120.27
5.6.40.0030.04320.07
5.6.30.0000.04720.04
5.6.20.0000.04420.30
5.6.10.0070.04620.16
5.6.00.0070.03620.25
5.5.380.0030.03817.34
5.5.370.0000.04317.34
5.5.360.0070.04217.47
5.5.350.0000.04417.29
5.5.340.0030.04418.05
5.5.330.0070.07517.86
5.5.320.0070.03518.07
5.5.310.0030.07917.63
5.5.300.0030.05617.77
5.5.290.0070.03718.07
5.5.280.0060.06417.86
5.5.270.0030.06217.88
5.5.260.0090.03917.88
5.5.250.0000.04517.84
5.5.240.0030.03817.36
5.5.230.0000.06417.14
5.5.220.0000.04217.11
5.5.210.0030.06217.27
5.5.200.0000.04517.09
5.5.190.0070.03617.23
5.5.180.0040.03917.12
5.5.160.0000.04617.21
5.5.150.0060.03817.27
5.5.140.0090.03417.34
5.5.130.0030.03817.20
5.5.120.0060.03817.12
5.5.110.0030.05416.97
5.5.100.0070.03817.14
5.5.90.0060.03716.88
5.5.80.0070.03616.99
5.5.70.0030.03817.22
5.5.60.0090.03117.14
5.5.50.0060.03917.16
5.5.40.0060.04117.15
5.5.30.0100.03316.84
5.5.20.0090.03217.14
5.5.10.0070.03317.23
5.5.00.0000.04117.22
5.4.450.0000.06419.10
5.4.440.0030.04719.13
5.4.430.0030.04519.23
5.4.420.0030.04219.48
5.4.410.0030.03819.05
5.4.400.0000.03919.10
5.4.390.0000.04019.04
5.4.380.0070.05618.94
5.4.370.0030.04219.05
5.4.360.0000.04518.91
5.4.350.0070.03719.14
5.4.340.0070.04018.87
5.4.320.0000.04518.86
5.4.310.0030.03618.85
5.4.300.0030.03719.01
5.4.290.0030.03819.05
5.4.280.0070.03819.03
5.4.270.0030.04119.09
5.4.260.0030.04218.78
5.4.250.0000.05019.05
5.4.240.0000.04018.77
5.4.230.0030.03819.03
5.4.220.0070.03618.86
5.4.210.0040.04218.83
5.4.200.0000.04119.02
5.4.190.0030.03719.12
5.4.180.0040.03618.77
5.4.170.0060.03518.89
5.4.160.0000.05819.03
5.4.150.0070.03619.12
5.4.140.0070.04516.57
5.4.130.0000.04216.70
5.4.120.0040.03516.66
5.4.110.0000.05216.65
5.4.100.0000.04216.49
5.4.90.0060.03516.50
5.4.80.0000.04116.73
5.4.70.0000.04116.50
5.4.60.0030.03816.42
5.4.50.0000.03816.58
5.4.40.0000.04016.73
5.4.30.0070.03216.64
5.4.20.0000.04216.58
5.4.10.0070.04916.43
5.4.00.0000.03816.06
5.3.290.0070.04015.18
5.3.280.0000.04115.18
5.3.270.0000.04415.18
5.3.260.0030.03815.18
5.3.250.0030.03915.18
5.3.240.0030.03815.18
5.3.230.0230.03915.18
5.3.220.0000.08015.18
5.3.210.0100.03015.18
5.3.200.0030.03715.18
5.3.190.0070.03615.18
5.3.180.0070.03715.18
5.3.170.0030.04015.18
5.3.160.0000.04215.18
5.3.150.0000.04015.18
5.3.140.0030.03815.18
5.3.130.0030.03615.18
5.3.120.0030.03815.18
5.3.110.0030.03915.18
5.3.100.0100.03315.18
5.3.90.0030.04415.18
5.3.80.0000.03715.18
5.3.70.0030.03515.18
5.3.60.0000.04115.18
5.3.50.0030.03715.18
5.3.40.0030.03415.18
5.3.30.0000.03915.18
5.3.20.0060.03415.18
5.3.10.0000.03715.18
5.3.00.0030.03415.18
5.2.170.0060.02515.18
5.2.160.0070.02615.18
5.2.150.0030.03015.18
5.2.140.0030.02815.18
5.2.130.0030.03615.18
5.2.120.0000.03015.18
5.2.110.0070.02315.18
5.2.100.0000.03015.18
5.2.90.0000.03015.18
5.2.80.0030.03115.18
5.2.70.0030.03115.18
5.2.60.0030.02915.18
5.2.50.0060.03015.18
5.2.40.0070.02315.18
5.2.30.0040.02815.18
5.2.20.0070.02615.18
5.2.10.0060.02315.18
5.2.00.0040.02915.18
5.1.60.0000.02815.18
5.1.50.0000.02815.18
5.1.40.0000.05415.18
5.1.30.0000.03815.18
5.1.20.0030.02415.18
5.1.10.0060.02515.18
5.1.00.0030.02415.18
5.0.50.0000.02115.18
5.0.40.0000.02915.18
5.0.30.0000.03115.18
5.0.20.0030.01915.18
5.0.10.0030.01915.18
5.0.00.0040.02815.18
4.4.90.0000.01715.18
4.4.80.0000.01915.18
4.4.70.0000.01815.18
4.4.60.0030.01415.18
4.4.50.0000.01615.18
4.4.40.0030.02415.18
4.4.30.0000.01715.18
4.4.20.0000.01815.18
4.4.10.0000.01615.18
4.4.00.0000.03815.18
4.3.110.0000.01615.18
4.3.100.0030.01515.18
4.3.90.0000.01815.18
4.3.80.0030.02415.18
4.3.70.0000.01715.18
4.3.60.0030.01315.18
4.3.50.0000.01915.18
4.3.40.0110.01415.18
4.3.30.0060.01315.18
4.3.20.0000.02415.18
4.3.10.0000.01815.18
4.3.00.0030.01515.18

preferences:
40.79 ms | 401 KiB | 5 Q