<?php
$sum = null; // global variable
function outer() {
global $sum;
$hundred_more = 100;
$sum = function ($a, $b) use ($hundred_more) {
return $a + $b + (++$hundred_more);
};
println($hundred_more);
}
outer(); // define sum at the global scope and print 100
echo($sum(5, 10)); // 116
echo($sum(5, 10)); // 117
outer(); // redefine sum at the global scope and print 100
echo($sum(5, 10)); // 116
echo($sum(5, 10)); // 117
Fatal error: Uncaught Error: Call to undefined function println() in /in/vK2R2:11
Stack trace:
#0 /in/vK2R2(13): outer()
#1 {main}
thrown in /in/vK2R2 on line 11
Process exited with code 255.