3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface iPropulsion { public function accelerate(); public function decelerate(); } interface iOrdonance { public function lockOn(); public function fire(); } class CarEngine implements iPropulsion { public function accelerate() { return "increase revs to 3000... This should shake yer kidney stones..."; } public function decelerate() { return "decrease revs to 1000"; } } class JetEngine implements iPropulsion { public function accelerate() { return "increase revs to 20000... To the ends of skies..."; } public function decelerate() { return "decrease revs to 5000"; } } class Cannon implements iOrdonance { public function lockOn() { return "Srsly?! Just point and shoot, how hard is that..."; } public function Fire() { return "Dagagagagaga!"; } } class Rocket implements iOrdonance { public function lockOn() { return "Beep... Beep... Beeeeeeeeeeeep..."; } public function Fire() { return "Swhooosh! Ka-Boom!"; } } class Vehicle { private $propulsion = null; private $ordonance = null; public function __construct(iPropulsion $propulsion, iOrdonance $ordonance) { $this->propulsion = $propulsion; $this->ordonance = $ordonance; } public function start() { print $this->propulsion->accelerate() . PHP_EOL; } public function stop() { print $this->propulsion->decelerate() . PHP_EOL; } public function lockOn() { print $this->ordonance->lockOn() . PHP_EOL; } public function fire() { print $this->ordonance->fire() . PHP_EOL; } public function setPropulsion(iPropulsion $propulsion) { $this->propulsion = $propulsion; } public function setOrdonance(iOrdonance $ordonance) { $this->ordonance = $ordonance; } } print "Hey I want a new fighting vehicle... With a Cannon!" . PHP_EOL; $fighter = new Vehicle(new CarEngine(), new Cannon()); print "Peel off" . PHP_EOL; $fighter->start(); print "Hey I want some target practice :)" . PHP_EOL; print "Going to lock on the target" . PHP_EOL; $fighter->lockOn(); print "Time to blow stuff up" . PHP_EOL; $fighter->fire(); print "This sux, moving too slow :(" . PHP_EOL; $fighter->stop(); print "I need a better engine, mekkaniku-san, and rockets, lotsalotsa rockets, kthxbai" . PHP_EOL; $fighter->setPropulsion(new JetEngine()); $fighter->setOrdonance(new Rocket()); print "Once again into the fray" . PHP_EOL; $fighter->start(); print "Going to lock on the target, hopefully this will go better than last time" . PHP_EOL; $fighter->lockOn(); print "Yeeehaw" . PHP_EOL; $fighter->fire(); print "Control, one bogey down" . PHP_EOL;
Output for 5.0.2 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Hey I want a new fighting vehicle... With a Cannon! Peel off increase revs to 3000... This should shake yer kidney stones... Hey I want some target practice :) Going to lock on the target Srsly?! Just point and shoot, how hard is that... Time to blow stuff up Dagagagagaga! This sux, moving too slow :( decrease revs to 1000 I need a better engine, mekkaniku-san, and rockets, lotsalotsa rockets, kthxbai Once again into the fray increase revs to 20000... To the ends of skies... Going to lock on the target, hopefully this will go better than last time Beep... Beep... Beeeeeeeeeeeep... Yeeehaw Swhooosh! Ka-Boom! Control, one bogey down
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 108 Hey I want a new fighting vehicle... With a Cannon!PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 111 Peel offPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 79 increase revs to 3000... This should shake yer kidney stones...PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 114 Hey I want some target practice :)PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 115 Going to lock on the targetPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 89 Srsly?! Just point and shoot, how hard is that...PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 118 Time to blow stuff upPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 94 Dagagagagaga!PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 121 This sux, moving too slow :(PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 84 decrease revs to 1000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 124 I need a better engine, mekkaniku-san, and rockets, lotsalotsa rockets, kthxbaiPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 128 Once again into the frayPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 79 increase revs to 20000... To the ends of skies...PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 131 Going to lock on the target, hopefully this will go better than last timePHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 89 Beep... Beep... Beeeeeeeeeeeep...PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 134 YeeehawPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 94 Swhooosh! Ka-Boom!PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nsUq8 on line 136 Control, one bogey downPHP_EOL
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/nsUq8 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/nsUq8 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/nsUq8 on line 3
Process exited with code 255.

preferences:
250.6 ms | 401 KiB | 351 Q