3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* class Pont { } $towerBridge = new Pont; $towerBridge->__construct(12.2, 43.1); */ class Player { private int $level; private Weapon $weapon; public function __construct(int $level) { $this->level = $level; } public function getLevel(): int { return $this->level; } public function setLevel(int $level) : void { $this->level = $level; } public function getWeapon(): Weapon { return $this->weapon; } public function setWeapon(Weapon $weapon) : void { $this->weapon = $weapon; } } class Weapon { private string $name; private int $attack; public function __construct(string $name, int $attack) { $this->name = $name; $this->attack = $attack; } public function getName(): string { return $this->name; } public function setName(string $name) : void { $this->name = $name; } public function getAttack(): int { return $this->attack; } public function setAttack(int $attack) : void { $this->attack = $attack; } } $masterSword = new Weapon("Master Sword", 1000); $link = new Player(4); $link->setWeapon($masterSword); echo "Link est de niveau ".$link->getLevel()."et il possède la ".$link->getWeapon()->name;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Cannot access private property Weapon::$name in /in/6vvOu:81 Stack trace: #0 {main} thrown in /in/6vvOu on line 81
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:
30.76 ms | 401 KiB | 8 Q