3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Shipping { private $company; function __construct(){ $this->company = ""; } function setStrategy($company){ $this->company = $company; } function calculate (Package $package){ return $this->company->calculate($package); } } interface Company { public function calculate(); } class UPS implements Company{ public function calculate($package){ return 45 * $package->weight; } } class USPS implements Company{ public function calculate(Package $package){ return 30 * $package->weight; } } class FedEx implements Company { public function calculate(Package $package){ return 60 * $package->weight; } } class Package { public $weight; function __construct($weight){ $this->weight = $weight; } } $package = new Package(30); $shipping = new Shipping(); $shiping->setStrategy(new UPS()); echo $shipping->calculate($package);
Output for git.master_jit, git.master, rfc.property-hooks
Fatal error: Declaration of UPS::calculate($package) must be compatible with Company::calculate() in /in/cHAPU on line 27
Process exited with code 255.

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:
63.13 ms | 401 KiB | 8 Q