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) { print_r($node); echo 'Property exists: '.$prop; if (!property_exists($node, $prop)) { $val = null; break; } $val = $node->$prop; $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 ) ) stdClass Object ( [name] => Fred [job] => stdClass Object ( [position] => Janitor [years] => 4 ) ) Property exists: jobstdClass Object ( [position] => Janitor [years] => 4 ) Property exists: yearsYears 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:
52.7 ms | 401 KiB | 8 Q