3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReadOnly { protected $realProperty; private $dynamicProperty = array(); function __construct() { $realProperty = 12; $this->members['test'] = 'read-only'; } public function __set($name, $value) { if($name=='test') { if(isset($this->dynamicProperty[$name])) throw new Exception("Can't overwrite $name"); $props[$name] = $value; } } } class Writeable extends ReadOnly { function __construct($value) { parent::__construct(); $this->realProperty = 25; // ok $this->test = $value; // causes Fatal Error } } $test = new Writeable('write to me');
Output for git.master, git.master_jit, rfc.property-hooks
Parse error: syntax error, unexpected token "readonly", expecting identifier in /in/oQ03I on line 3
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:
41.6 ms | 401 KiB | 8 Q