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 '4'; } } $answer = new Answer(); // 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.0090.00618.43
8.3.60.0120.00318.31
8.3.50.0110.00721.99
8.3.40.0040.01418.87
8.3.30.0070.00719.21
8.3.20.0080.00020.37
8.3.10.0040.00422.10
8.3.00.0070.00022.44
8.2.190.0090.00616.58
8.2.180.0120.00316.63
8.2.170.0120.00622.96
8.2.160.0100.00320.35
8.2.150.0000.00924.18
8.2.140.0080.00024.66
8.2.130.0100.01026.16
8.2.120.0040.00419.78
8.2.110.0000.00919.18
8.2.100.0040.00717.91
8.2.90.0090.00019.08
8.2.80.0060.00319.41
8.2.70.0060.00317.63
8.2.60.0040.00417.93
8.2.50.0000.00818.07
8.2.40.0040.00418.16
8.2.30.0080.00018.19
8.2.20.0030.00517.56
8.2.10.0040.00417.68
8.2.00.0040.00417.66
8.1.280.0140.00325.92
8.1.270.0040.00420.36
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00722.17
8.1.230.0060.00619.01
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0060.00317.35
8.1.190.0040.00417.53
8.1.180.0000.00720.29
8.1.170.0030.00518.51
8.1.160.0000.00722.09
8.1.150.0030.00618.64
8.1.140.0000.00717.42
8.1.130.0000.00717.82
8.1.120.0000.00717.45
8.1.110.0020.00517.39
8.1.100.0060.00317.46
8.1.90.0040.00417.48
8.1.80.0000.00717.51
8.1.70.0030.00317.34
8.1.60.0000.00817.62
8.1.50.0050.00317.57
8.1.40.0050.00217.35
8.1.30.0030.00517.68
8.1.20.0040.00417.56
8.1.10.0000.00717.61
8.1.00.0000.00717.57
8.0.300.0030.00518.78
8.0.290.0070.00017.05
8.0.280.0000.00818.44
8.0.270.0000.00717.26
8.0.260.0060.00016.79
8.0.250.0030.00317.03
8.0.240.0030.00616.95
8.0.230.0040.00416.93
8.0.220.0000.00716.93
8.0.210.0030.00317.01
8.0.200.0060.00016.97
8.0.190.0000.00816.91
8.0.180.0040.00416.90
8.0.170.0070.00016.94
8.0.160.0030.00316.86
8.0.150.0070.00016.99
8.0.140.0070.00416.93
8.0.130.0050.00013.38
8.0.120.0040.00416.97
8.0.110.0000.00716.93
8.0.100.0080.00016.81
8.0.90.0000.00716.77
8.0.80.0150.00017.00
8.0.70.0050.00316.75
8.0.60.0080.00016.82
8.0.50.0000.00716.89
8.0.30.0110.00817.03
8.0.20.0140.00617.40
8.0.10.0050.00316.98
8.0.00.0100.00816.95
7.4.330.0050.00015.00
7.4.320.0030.00316.61
7.4.300.0000.00616.61
7.4.290.0030.00316.37
7.4.280.0000.00716.62
7.4.270.0050.00216.65
7.4.260.0070.00016.59
7.4.250.0000.00816.48
7.4.240.0050.00216.54
7.4.230.0000.00716.67
7.4.220.0160.01016.59
7.4.210.0050.01016.59
7.4.200.0030.00316.49
7.4.190.0070.00016.73
7.4.160.0090.00616.51
7.4.150.0090.00917.40
7.4.140.0120.00817.86
7.4.130.0110.01016.55
7.4.120.0080.00816.52
7.4.110.0030.01616.56
7.4.100.0030.01416.62
7.4.90.0170.00616.61
7.4.80.0070.01019.39
7.4.70.0110.01416.38
7.4.60.0160.00016.60
7.4.50.0030.00316.48
7.4.40.0070.00722.77
7.4.30.0100.00616.75
7.4.00.0120.00515.01
7.3.330.0030.00213.20
7.3.320.0000.00613.32
7.3.310.0000.00716.19
7.3.300.0070.00016.24
7.3.290.0060.01216.34
7.3.280.0100.00916.36
7.3.270.0090.00917.40
7.3.260.0100.00716.38
7.3.250.0040.01616.44
7.3.240.0170.00516.44
7.3.230.0170.00616.50
7.3.210.0090.00916.54
7.3.200.0100.00719.39
7.3.190.0160.00316.28
7.3.180.0100.00616.48
7.3.170.0100.00616.29
7.3.160.0090.00616.52
7.3.120.0030.01414.94
7.3.110.0080.00815.02
7.3.100.0080.00414.68
7.3.90.0110.00314.89
7.3.80.0060.00914.88
7.3.70.0040.00414.88
7.3.60.0120.00014.61
7.3.50.0110.00414.75
7.3.40.0060.00614.94
7.3.30.0110.00414.86
7.3.20.0000.01216.57
7.3.10.0100.00316.81
7.3.00.0080.00516.70
7.2.330.0060.01116.84
7.2.320.0100.00716.66
7.2.310.0040.01416.71
7.2.300.0000.01616.66
7.2.290.0100.00616.57
7.2.250.0120.00614.83
7.2.240.0040.01515.27
7.2.230.0090.00614.91
7.2.220.0060.00914.89
7.2.210.0030.00915.14
7.2.200.0100.00315.22
7.2.190.0000.01015.02
7.2.180.0060.01015.02
7.2.170.0030.00915.16
7.2.130.0110.00416.98
7.2.120.0110.00316.63
7.2.110.0030.01216.60
7.2.100.0110.00716.96
7.2.90.0020.00916.43
7.2.80.0160.00016.48
7.2.70.0040.01116.81
7.2.60.0070.00816.72
7.2.50.0110.00616.79
7.2.40.0150.00416.98
7.2.30.0110.00716.75
7.2.20.0100.00716.79
7.2.10.0130.00316.79
7.2.00.0120.00616.95
7.1.330.0070.00715.68
7.1.320.0060.00915.83
7.1.310.0070.00715.65
7.1.300.0060.00315.91
7.1.290.0060.00615.79
7.1.280.0090.00615.68
7.1.270.0070.00715.63
7.1.260.0040.00815.72
7.1.250.0140.00415.31
7.1.240.0070.00715.63
7.1.230.0080.00415.31
7.1.220.0000.01415.66
7.1.210.0100.00315.61
7.1.200.0060.00615.59
7.1.190.0100.00515.71
7.1.180.0090.00915.77
7.1.170.0120.00315.41
7.1.160.0040.00815.80
7.1.150.0140.00315.56
7.1.140.0100.00715.60
7.1.130.0090.00615.20
7.1.120.0100.00715.63
7.1.110.0120.00315.95
7.1.100.0090.00615.61
7.1.90.0080.00815.76
7.1.80.0070.01015.56
7.1.70.0030.01016.38
7.1.60.0080.01117.49
7.1.50.0060.01116.25
7.1.40.0110.00815.63
7.1.30.0080.00815.54
7.1.20.0100.00715.40
7.1.10.0100.00715.55
7.1.00.0140.03319.02
7.0.330.0120.00915.24
7.0.320.0110.00815.13
7.0.310.0070.00715.41
7.0.300.0090.00615.36
7.0.290.0150.00315.20
7.0.280.0080.00815.13
7.0.270.0090.00615.12
7.0.260.0100.00715.12
7.0.250.0140.00015.50
7.0.240.0080.00815.41
7.0.230.0070.01014.96
7.0.220.0070.01115.29
7.0.210.0090.00915.07
7.0.200.0060.00615.96
7.0.190.0100.00615.07
7.0.180.0130.00315.11
7.0.170.0150.00615.00
7.0.160.0060.01315.15
7.0.150.0110.00415.39
7.0.140.0050.04418.77
7.0.130.0070.01115.06
7.0.120.0120.00915.28
7.0.110.0070.01515.34
7.0.100.0110.00415.07
7.0.90.0150.00415.33
7.0.80.0070.01014.87
7.0.70.0110.00415.33
7.0.60.0090.02217.59
7.0.50.0060.04316.58
7.0.40.0100.04416.75
7.0.30.0220.03316.76
7.0.20.0160.02416.70
7.0.10.0130.03916.89
7.0.00.0070.03816.58
5.6.380.0060.00914.03
5.6.370.0100.00714.57
5.6.360.0130.00814.29
5.6.350.0080.01214.47
5.6.340.0080.01614.14
5.6.330.0180.00814.24
5.6.320.0080.01214.30
5.6.310.0160.00814.44
5.6.300.0140.01114.24
5.6.290.0150.01214.42
5.6.280.0130.03817.72
5.6.270.0180.00714.24
5.6.260.0140.00314.55
5.6.250.0100.00314.33
5.6.240.0090.00614.52
5.6.230.0100.00714.23
5.6.220.0000.00814.49
5.6.210.0070.01817.43
5.6.200.0100.04116.15
5.6.190.0090.04317.53
5.6.180.0170.03717.40
5.6.170.0240.02317.53
5.6.160.0050.04817.42
5.6.150.0060.03516.19
5.6.140.0050.02216.18
5.6.130.0110.03816.30
5.6.120.0100.03417.70
5.6.110.0050.04717.55
5.6.100.0050.04617.62
5.6.90.0050.03917.57
5.6.80.0050.05017.50
5.6.70.0000.00814.11
5.6.60.0070.01014.12
5.6.50.0060.00614.01
5.6.40.0070.00714.04
5.6.30.0060.00914.23
5.6.20.0090.00614.17
5.6.10.0030.00914.43
5.6.00.0030.01014.05
5.5.380.0060.00611.16
5.5.370.0060.00610.58
5.5.360.0000.01311.02
5.5.350.0040.03215.57
5.5.340.0050.04314.63
5.5.330.0030.02215.94
5.5.320.0070.04415.73
5.5.310.0150.02015.71
5.5.300.0050.02014.59
5.5.290.0070.03314.44
5.5.280.0070.04416.04
5.5.270.0060.02616.10
5.5.260.0050.04516.00
5.5.250.0050.04615.83
5.5.240.0140.04315.59
5.5.230.0000.01010.85
5.5.220.0030.00710.98
5.5.210.0030.00710.80
5.5.200.0030.00311.00
5.5.190.0000.01010.78
5.5.180.0000.01011.08
5.5.170.0080.00010.79
5.5.160.0040.00710.97
5.5.150.0000.01010.77
5.5.140.0060.00510.53
5.5.130.0070.00010.71
5.5.120.0040.00411.00
5.5.110.0060.00611.17
5.5.100.0000.00710.79
5.5.90.0070.00410.96
5.5.80.0030.00310.95
5.5.70.0070.00410.82
5.5.60.0000.00610.89
5.5.50.0040.00711.09
5.5.40.0040.00410.84
5.5.30.0000.00810.57
5.5.20.0040.00710.99
5.5.10.0030.00910.90
5.5.00.0080.00010.79
5.4.450.0420.02415.38
5.4.440.0240.03315.40
5.4.430.0320.02215.27
5.4.420.0080.03015.22
5.4.410.0050.03115.19
5.4.400.0050.03214.89
5.4.390.0100.03414.97
5.4.380.0100.03214.97
5.4.370.0120.02515.03
5.4.360.0000.03715.10
5.4.350.0040.02411.38
5.4.340.0060.01911.38
5.4.330.0030.00610.70
5.4.320.0070.02011.73
5.4.310.0060.02311.60
5.4.300.0060.02211.79
5.4.290.0050.02311.71
5.4.280.0070.01911.68
5.4.270.0070.02611.73
5.4.260.0040.02611.61
5.4.250.0080.02714.85
5.4.240.0020.03414.79
5.4.230.0070.02814.99
5.4.220.0100.02714.92
5.4.210.0060.03014.81
5.4.200.0080.02714.74
5.4.190.0050.02714.94
5.4.180.0100.02414.85
5.4.170.0110.02214.92
5.4.160.0110.02414.74
5.4.150.0040.03214.85
5.4.140.0100.02613.53
5.4.130.0070.02613.48
5.4.120.0060.03813.50
5.4.110.0030.03213.72
5.4.100.0030.03813.56
5.4.90.0020.03113.68
5.4.80.0060.02913.72
5.4.70.0050.03013.56
5.4.60.0070.02713.55
5.4.50.0090.02313.65
5.4.40.0040.03013.53
5.4.30.0110.02513.72
5.4.20.0090.02513.39
5.4.10.0110.03713.66
5.4.00.0050.04013.27
5.3.290.0100.02311.63
5.3.280.0100.02312.62
5.3.270.0060.03012.70
5.3.260.0080.02712.45
5.3.250.0070.02712.59
5.3.240.0080.02612.62
5.3.230.0060.02812.49
5.3.220.0050.03312.56
5.3.210.0020.02912.43
5.3.200.0040.02912.46
5.3.190.0040.02912.57
5.3.180.0080.02512.57
5.3.170.0100.02312.58
5.3.160.0100.02512.65
5.3.150.0080.03512.63
5.3.140.0050.03112.65
5.3.130.0110.03212.46
5.3.120.0060.04312.62
5.3.110.0070.02612.59
5.3.100.0050.02712.31
5.3.90.0040.02912.26
5.3.80.0020.02912.34
5.3.70.0120.02212.21
5.3.60.0100.02612.40
5.3.50.0100.02712.33
5.3.40.0100.02712.16
5.3.30.0110.02412.37
5.3.20.0070.03512.04
5.3.10.0050.03112.04
5.3.00.0080.02912.02
5.2.170.0080.02110.69
5.2.160.0080.02010.81
5.2.150.0060.02310.62
5.2.140.0110.01810.70
5.2.130.0110.01710.68
5.2.120.0050.02210.76
5.2.110.0080.01910.67
5.2.100.0060.02110.72
5.2.90.0050.03110.63
5.2.80.0020.02610.66
5.2.70.0100.02010.72
5.2.60.0050.02110.69
5.2.50.0100.01710.69
5.2.40.0030.02510.74
5.2.30.0050.02310.61
5.2.20.0080.02210.61
5.2.10.0040.02310.59
5.2.00.0060.02010.61
5.1.60.0100.01310.12
5.1.50.0080.01710.12
5.1.40.0060.01810.15
5.1.30.0060.02010.34
5.1.20.0060.01810.30
5.1.10.0070.02010.19
5.1.00.0090.02410.15
5.0.50.0000.0199.33
5.0.40.0050.0139.38
5.0.30.0050.0289.24
5.0.20.0020.0179.22
5.0.10.0050.0159.18
5.0.00.0000.0259.18
4.4.90.0000.0158.35
4.4.80.0030.0128.35
4.4.70.0010.0158.35
4.4.60.0000.0188.35
4.4.50.0050.0108.35
4.4.40.0020.0218.35
4.4.30.0020.0128.35
4.4.20.0050.0118.35
4.4.10.0040.0128.35
4.4.00.0020.0218.35
4.3.110.0010.0138.35
4.3.100.0010.0108.35
4.3.90.0060.0118.35
4.3.80.0000.0228.35
4.3.70.0040.0108.35
4.3.60.0030.0118.35
4.3.50.0010.0138.35
4.3.40.0030.0178.35
4.3.30.0030.0128.35
4.3.20.0030.0128.35
4.3.10.0050.0108.35
4.3.00.0080.00712.38

preferences:
117.54 ms | 401 KiB | 5 Q