3v4l.org

run code in 300+ PHP versions simultaneously
<?php class v { public $foo = 'foo!'; private $privates = []; public function __get($n) { if (isset($this->privates[$n])) { return $this->privates[$n]; } throw new exception("{$n} is not accessible"); } public function __set($n, $v) { if (isset($this->privates[$n])) { throw new exception("{$n} is read-only"); } $this->$n = $v; } public function makeReadonly() { $this->privates['foo'] = $this->foo; unset($this->foo); } } $v = new v; echo $v->foo, "\n"; $v->foo = 'bar!'; echo $v->foo, "\n"; $v->makeReadonly(); echo $v->foo, "\n"; $v->foo = 'foo!';
Output for git.master, git.master_jit, rfc.property-hooks
foo! bar! bar! Fatal error: Uncaught Exception: foo is read-only in /in/EQ1G2:18 Stack trace: #0 /in/EQ1G2(38): v->__set('foo', 'foo!') #1 {main} thrown in /in/EQ1G2 on line 18
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:
27.27 ms | 401 KiB | 8 Q