For example I have the following code:
function a($param) { function b() { echo $param; } b(); } a("Hello World!"); That throws an E_NOTICE error because $param is of course undefined (in b()).
I cannot pass $param to b() because b() should be a callback function of preg_replace_callback(). So I had the idea to save $param in $GLOBALS.
Is there any better solution?
bwould be called a closure if it has access to$param.