3v4l.org

run code in 300+ PHP versions simultaneously
<?php # Model class Car { private $name = null; private $description = null; private $price = 0; public function __construct($name, $price, $description = null) { $this->name = $name; $this->description = $description; $this->price = $price; } public function setName($name) {$this->name = $name;} public function getName() {return $this->name; } public function setDescription($description) {$this->description = $description; } public function getDescription() {return $this->description; } public function setPrice($price) {$this->price = $price;} public function getPrice() {return $this->price;} } # Presenter class CarPresenter { private $car; public function __construct($car) { $this->car = $car; } public function __call($method, $params = array()) { #if(method_exists($this, $method)) { # call_user_func_array(array($this, $method), $params); #} else if(method_exists($this->car, $method)) { call_user_func_array(array($this->car, $method), $params); } } public function isExpesive() { return $this->car->getPrice() > 45000; } public function getDescription() { $description = $this->car->getDescription(); return is_null($description) ? 'No description' : $description; } } $car = new Car('Ferrari', 2000000); $car_presenter = new CarPresenter($car); echo $car_presenter->getName(); echo $car_presenter->isExpensive(); echo $car_presenter->getDescription();
Output for git.master, git.master_jit, rfc.property-hooks
No description

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