3v4l.org

run code in 300+ PHP versions simultaneously
<?php // create array of objects $arr = [new stdClass, new stdClass, new StdClass]; // assign properties for($i=0, $max=count($arr); $i < $max; $i++) { $arr[$i]->age = 0; $arr[$i]->creature = "squirrel"; } // update age values $arr[0]->age = 10; $arr[1]->age = 25; $arr[2]->age = 30; // recursively sum the ages of the array of objects ... function getTotalYears( $arr, $i, $carry ) { if ($i >= ( count( $arr ) - 1 ) ){ return $carry; } else { $carry += $arr[$i++]->age; getTotalYears( $arr, $i, $carry ); } } // .. and display result $total = getTotalYears( $arr, 0, 0); var_dump($total); echo "\nTotal years of nut foraging experience: $total";
Output for git.master, git.master_jit, rfc.property-hooks
NULL Total years of nut foraging experience:

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