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 __toString() { return "4"; } public function get() { return $this; } public function the() { return $this; } public function answer() { return $this; } } // 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.40.0070.01018.58
8.3.30.0090.00618.69
8.3.20.0080.00018.81
8.3.10.0060.00320.21
8.3.00.0030.00517.63
8.2.170.0000.01522.96
8.2.160.0070.00722.14
8.2.150.0000.00824.18
8.2.140.0070.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00419.77
8.2.110.0090.00021.00
8.2.100.0080.00317.78
8.2.90.0000.00819.14
8.2.80.0080.00017.80
8.2.70.0030.00517.63
8.2.60.0050.00317.92
8.2.50.0000.00818.07
8.2.40.0050.00319.88
8.2.30.0040.00418.10
8.2.20.0040.00417.73
8.2.10.0050.00317.58
8.2.00.0040.00417.66
8.1.270.0060.00324.66
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0030.00620.81
8.1.230.0080.00320.88
8.1.220.0000.00817.74
8.1.210.0000.00819.01
8.1.200.0060.00317.35
8.1.190.0000.00817.53
8.1.180.0040.00418.10
8.1.170.0070.00018.65
8.1.160.0000.00718.79
8.1.150.0070.00018.64
8.1.140.0030.00617.50
8.1.130.0070.00017.89
8.1.120.0070.00017.50
8.1.110.0000.00717.42
8.1.100.0000.00717.41
8.1.90.0000.00717.35
8.1.80.0000.00817.46
8.1.70.0000.00717.39
8.1.60.0000.00717.57
8.1.50.0030.00617.30
8.1.40.0050.00317.53
8.1.30.0030.00617.51
8.1.20.0040.00417.63
8.1.10.0040.00417.55
8.1.00.0000.00717.51
8.0.300.0020.00520.02
8.0.290.0040.00416.75
8.0.280.0000.00718.37
8.0.270.0050.00217.22
8.0.260.0040.00416.82
8.0.250.0030.00316.93
8.0.240.0040.00416.99
8.0.230.0000.00717.00
8.0.220.0000.00716.86
8.0.210.0000.00716.96
8.0.200.0000.00717.01
8.0.190.0050.00316.92
8.0.180.0040.00416.91
8.0.170.0060.00316.96
8.0.160.0050.00216.95
8.0.150.0070.00016.91
8.0.140.0000.00816.95
8.0.130.0000.00513.42
8.0.120.0080.00016.89
8.0.110.0040.00416.99
8.0.100.0070.00016.82
8.0.90.0040.00416.98
8.0.80.0090.00616.99
8.0.70.0030.00516.95
8.0.60.0050.00316.93
8.0.50.0000.00716.78
8.0.30.0100.01017.00
8.0.20.0160.00517.25
8.0.10.0000.00817.14
8.0.00.0140.01216.72
7.4.330.0050.00014.70
7.4.320.0040.00416.59
7.4.300.0060.00016.57
7.4.290.0070.00016.59
7.4.280.0000.01016.63
7.4.270.0030.00316.50
7.4.260.0000.00513.13
7.4.250.0000.00916.50
7.4.240.0030.00316.66
7.4.230.0030.00316.68
7.4.220.0110.00516.50
7.4.210.0080.00816.55
7.4.200.0000.00716.51
7.4.190.0030.00316.77
7.4.160.0090.00616.63
7.4.150.0030.01417.07
7.4.140.0130.00517.20
7.4.130.0100.01316.54
7.4.120.0080.01016.62
7.4.110.0060.01316.38
7.4.100.0100.00716.54
7.4.90.0110.00616.62
7.4.80.0070.01018.80
7.4.70.0140.00916.51
7.4.60.0110.01116.46
7.4.50.0040.00423.17
7.4.40.0060.00921.69
7.4.30.0140.00716.57
7.4.00.0070.01015.04
7.3.330.0000.00613.18
7.3.320.0040.00413.22
7.3.310.0030.00316.34
7.3.300.0070.00016.38
7.3.290.0130.00316.37
7.3.280.0060.00916.36
7.3.270.0090.01017.07
7.3.260.0100.00818.24
7.3.250.0090.01016.47
7.3.240.0160.00016.66
7.3.230.0150.00316.52
7.3.210.0100.00716.37
7.3.200.0110.00719.39
7.3.190.0100.00716.44
7.3.180.0130.00316.60
7.3.170.0070.01316.50
7.3.160.0160.00016.47
7.3.120.0070.00914.66
7.3.110.0000.01714.86
7.3.100.0150.00014.92
7.3.90.0160.00014.76
7.3.80.0000.01414.83
7.3.70.0040.01114.80
7.3.60.0060.01214.87
7.3.50.0070.00714.64
7.3.40.0030.01014.77
7.3.30.0070.01014.50
7.3.20.0070.00716.68
7.3.10.0040.01116.67
7.3.00.0080.00816.36
7.2.330.0110.00716.54
7.2.320.0100.00616.70
7.2.310.0130.00616.69
7.2.300.0030.01316.77
7.2.290.0170.00616.40
7.2.250.0040.01914.84
7.2.240.0130.00715.12
7.2.230.0030.01314.88
7.2.220.0060.00614.67
7.2.210.0030.01114.77
7.2.200.0070.00715.11
7.2.190.0040.01415.00
7.2.180.0100.00714.90
7.2.170.0070.01015.09
7.2.60.0040.00816.78
7.2.00.0090.00319.21
7.1.330.0040.01115.72
7.1.320.0000.01615.85
7.1.310.0120.00315.84
7.1.300.0040.01215.64
7.1.290.0070.00715.79
7.1.280.0000.00915.79
7.1.270.0070.00715.84
7.1.260.0000.01115.75
7.1.200.0030.01015.73
7.1.100.0090.00318.26
7.1.70.0040.00417.02
7.1.60.0060.00919.40
7.1.50.0030.01917.02
7.1.00.0030.07022.35
7.0.200.0060.00616.78
7.0.140.0070.07022.00
7.0.120.0000.03721.95
7.0.60.0070.08020.00
7.0.50.0030.04317.87
7.0.40.0030.06720.24
7.0.30.0230.07020.20
7.0.20.0370.07720.33
7.0.10.0200.05020.23
7.0.00.0070.04320.23
5.6.280.0000.07720.86
5.6.210.0100.08320.62
5.6.200.0070.07318.18
5.6.190.0130.08320.33
5.6.180.0200.04320.61
5.6.170.0200.03720.54
5.6.160.0030.04020.39
5.6.150.0000.06018.19
5.6.140.0070.06718.12
5.6.130.0170.05018.18
5.6.120.0100.06020.98
5.6.110.0130.08321.04
5.6.100.0170.07721.15
5.6.90.0200.08021.14
5.6.80.0100.07320.42
5.6.70.4170.03720.39
5.5.350.0300.03720.54
5.5.340.0070.08017.96
5.5.330.0100.04020.25
5.5.320.0000.05320.48
5.5.310.0100.04720.27
5.5.300.0070.07017.95
5.5.290.0170.06717.95
5.5.280.0100.04020.89
5.5.270.0070.08320.90
5.5.260.0100.05320.96
5.5.250.0070.08020.55
5.5.240.0130.06020.22
5.4.450.2100.04319.41
5.4.440.1970.04319.54
5.4.430.2070.05019.16
5.4.420.1670.04019.20
5.4.410.1930.03719.25
5.4.400.2100.04319.34
5.4.390.2030.04318.84
5.4.380.2130.04319.08
5.4.370.2070.04319.00
5.4.360.2130.03719.21
5.4.350.2070.04019.00
5.4.340.1870.04019.26
5.4.320.2070.04719.19
5.4.310.2100.04018.83
5.4.300.2000.04019.13
5.4.290.1900.04018.99
5.4.280.0170.04718.84
5.4.270.0100.07719.17
5.4.260.0100.07319.19
5.4.250.1170.05718.83
5.4.240.1970.04019.25
5.4.230.2070.04718.98
5.4.220.2030.04019.12
5.4.210.1930.03318.83
5.4.200.2200.03719.19
5.4.190.2100.04319.08
5.4.180.2200.03319.30
5.4.170.2000.05019.20
5.4.160.1830.04319.13
5.4.150.1730.04719.06
5.4.140.1930.03716.52
5.4.130.2170.04016.71
5.4.120.2070.04716.43
5.4.110.2070.03716.61
5.4.100.2030.04716.61
5.4.90.2070.04316.47
5.4.80.2130.04016.58
5.4.70.1870.03716.59
5.4.60.2130.03316.50
5.4.50.1200.04316.43
5.4.40.0030.06016.56
5.4.30.0100.03716.43
5.4.20.0030.04316.23
5.4.10.1930.03316.36
5.4.00.2100.04315.90
5.3.290.2000.03714.64
5.3.280.1870.04014.71
5.3.270.2230.04314.52
5.3.260.2100.04314.61
5.3.250.1930.03314.70
5.3.240.1830.04014.54
5.3.230.2100.04714.63
5.3.220.2270.04014.55
5.3.210.2070.03714.63
5.3.200.1870.03714.50
5.3.190.1870.04314.63
5.3.180.1970.04314.47
5.3.170.2070.04014.54
5.3.160.1970.03314.79
5.3.150.1470.05014.66
5.3.140.0070.07314.46
5.3.130.0000.04014.56
5.3.120.1170.03714.53
5.3.110.2130.03714.56
5.3.100.2270.03314.19
5.3.90.1930.03013.94
5.3.80.2100.04013.93
5.3.70.1970.04714.10
5.3.60.2070.04014.09
5.3.50.1770.04313.97
5.3.40.2100.03314.04
5.3.30.1830.03713.92
5.3.20.2130.03313.72
5.3.10.0030.05013.68
5.3.00.0000.04313.87
5.2.170.0770.03311.04
5.2.160.1470.03311.21
5.2.150.1530.02711.27
5.2.140.1470.04311.08
5.2.130.1470.02711.07
5.2.120.1430.02711.04
5.2.110.1570.02311.16
5.2.100.1330.02711.20
5.2.90.0030.02711.02
5.2.80.0000.03011.01
5.2.70.0000.03311.26
5.2.60.0000.04711.01
5.2.50.1500.03010.95
5.2.40.1130.03310.93
5.2.30.1230.03011.13
5.2.20.0430.02711.12
5.2.10.0000.03010.80
5.2.00.0000.03710.80
5.1.60.0030.0239.91
5.1.50.0530.02710.00
5.1.40.0700.0309.89
5.1.30.1270.03310.46
5.1.20.1300.03710.27
5.1.10.0800.02710.01
5.1.00.1070.02010.21
5.0.50.0600.0238.55
5.0.40.0430.0208.50
5.0.30.0600.0308.46
5.0.20.0400.0208.14
5.0.10.0470.0208.41
5.0.00.0570.0378.40
4.4.90.0500.0176.02
4.4.80.0600.0136.03
4.4.70.0670.0176.03
4.4.60.0630.0136.05
4.4.50.0430.0136.07
4.4.40.0500.0276.07
4.4.30.0630.0136.07
4.4.20.0600.0176.07
4.4.10.0570.0176.07
4.4.00.0600.0276.09
4.3.110.0570.0106.09
4.3.100.0770.0176.10
4.3.90.0630.0136.11
4.3.80.0630.0236.13
4.3.70.0570.0106.13
4.3.60.0630.0176.13
4.3.50.0470.0176.14
4.3.40.0470.0236.14
4.3.30.0300.0176.14
4.3.20.0330.0136.14
4.3.10.0330.0106.14
4.3.00.0370.0176.14

preferences:
42.04 ms | 400 KiB | 5 Q