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 new Answer();} public function the() { return new Answer();} public function answer() { return 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)
5.4.270.0070.07318.92
5.4.260.0070.05318.83
5.4.250.0170.04719.09
5.4.240.0070.05718.98
5.4.230.0130.07319.10
5.4.220.0000.06018.80
5.4.210.0230.04718.88
5.4.200.0030.05719.02
5.4.190.0200.04718.76
5.4.180.0130.05018.96
5.4.170.0130.05319.03
5.4.160.0200.04318.85
5.4.150.0170.07318.89
5.4.140.0130.05016.55
5.4.130.0070.05316.53
5.4.120.0130.05016.45
5.4.110.0230.06016.58
5.4.100.0170.04716.58
5.4.90.0070.06716.64
5.4.80.0130.05716.57
5.4.70.0130.06716.54
5.4.60.0170.04716.40
5.4.50.0170.04316.39
5.4.40.0170.05716.46
5.4.30.0070.05716.44
5.4.20.0100.05716.32
5.4.10.0130.05016.58
5.4.00.0170.04715.93
5.3.280.0130.06014.64
5.3.270.0130.06314.49
5.3.260.0200.04714.77
5.3.250.0270.03714.64
5.3.240.0030.06714.57
5.3.230.0170.07014.85
5.3.220.0070.05314.80
5.3.210.0070.07314.54
5.3.200.0100.07714.53
5.3.190.0200.04314.53
5.3.180.0070.05314.55
5.3.170.0100.06314.59
5.3.160.0130.04714.84
5.3.150.0070.06314.45
5.3.140.0200.04314.83
5.3.130.0100.05014.82
5.3.120.0030.06714.73
5.3.110.0130.06714.83
5.3.100.0100.05014.16
5.3.90.0070.05714.20
5.3.80.0130.05014.32
5.3.70.0130.05014.31
5.3.60.0030.06314.03
5.3.50.0100.04714.01
5.3.40.0100.06314.08
5.3.30.0330.04714.22
5.3.20.0070.06313.88
5.3.10.0130.06313.96
5.3.00.0100.07013.94

preferences:
136.62 ms | 1398 KiB | 7 Q