Perhaps this is because your closure syntax is incorrect. As far as I know, a closure should not have names. For instance. for the preg_replace_callback function, you will either pass a variable containing the closure defined with function($matches){/* logic */} , or the above code.
What you are trying to do here is to define a function in the callback argument. BAAAAD for your xD script
Just get rid of a name like this and see if it helps:
myfunc(function(){ echo "hello"; if(1==2){ echo "world"; } });
PHP docs also show this syntax: http://php.net/manual/en/functions.anonymous.php
source share