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 git.master, git.master_jit, rfc.property-hooks
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

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
33.01 ms | 402 KiB | 8 Q