3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { protected $id; public function __set($key, $value) { if (isset($this->$key)) $this->$key = $value; // throw new Exception() could be added here } public function __get($key) { return isset($this->$key) ? $this->$key : null; } public function __call($name, $arguments) { $matches = array(); $pattern = '/^set([A-Za-z0-9]+)/'; if (preg_match($pattern, $name, $matches)) { //var_dump($arguments, $matches); $method = strtolower($mwtches[1]); $this->$method($arguments[0]); } } } $test = new Test; $test->setId(25); var_dump($test);
Output for git.master, git.master_jit
Warning: Undefined variable $mwtches in /in/TGht8 on line 25 Warning: Trying to access array offset on value of type null in /in/TGht8 on line 25 Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /in/TGht8 on line 25 object(Test)#1 (1) { ["id":protected]=> NULL }
Output for rfc.property-hooks
Warning: Undefined variable $mwtches in /in/TGht8 on line 25 Warning: Trying to access array offset on null in /in/TGht8 on line 25 Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /in/TGht8 on line 25 object(Test)#1 (1) { ["id":protected]=> NULL }

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