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); echo 'Years in current job: '.string($obj, 'job->years').PHP_EOL; function string($obj, $path_str) { $val = null; $path = preg_split('/(\.|->)/', $path_str); $node = $obj; while (($prop = array_shift($path)) !== null) { if (!is_object($obj) || !property_exists($node, $prop)) { $val = null; break; } $val = $node->$prop; // TODO: Insert any logic here for cleaning up $val $node = $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 ) ) Years in current job: 4

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