3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 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->accelerate(); print "Hey I want some target practice :)" . PHP_EOL; print "Going to lock on the target" . PHP_EOL; $fighter->lockOn();
Output for 5.1.0 - 5.4.32
Parse error: syntax error, unexpected '(', expecting '{' in /in/EQ7a9 on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '(', expecting '{' in /in/EQ7a9 on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/EQ7a9 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/EQ7a9 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/EQ7a9 on line 3
Process exited with code 255.