3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = new stdClass(); $obj->name = 'Fred'; $obj->job = new stdClass(); $obj->job->position = 'Janitor'; $obj->job->years = 4; print_r($obj); string($obj, 'job->years'); function string($obj, $path_str) { $val = null; $path = preg_split('/->/', $path_str); $node = $obj; while (($prop = array_shift($path)) !== null) { if (!property_exists($node, $prop)) { $val = null; break; } $node = $node->$prop; $val = $node->$prop; } return $val; }
Output for git.master, git.master_jit, rfc.property-hooks
stdClass Object ( [name] => Fred [job] => stdClass Object ( [position] => Janitor [years] => 4 ) ) Warning: Undefined property: stdClass::$job in /in/1kRgp on line 25 Warning: Attempt to read property "years" on int in /in/1kRgp on line 25

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.22 ms | 402 KiB | 8 Q