3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = 10; function outer($x) { function inner($y) { global $x; // uses the actually global $x from line 2, not the param from line 3 return $x + $y; } return inner(5); } echo outer(5); // expected: 10, actual: 15 /* $z = 10; function outer2($z) { function inner($w) use ($z) { // syntax error, function (...) use (...) form is reserved for closures return $z + $w; } return inner(5); } echo outer2(5); // expected: 10, actual: syntax error */
Output for git.master, git.master_jit, rfc.property-hooks
15

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