From: jexus at jexus dot net Operating system: Linux PHP version: 5.1.4 PHP Bug Type: Scripting Engine problem Bug description: __FUNCTION__ does not work inside create_function
Description: ------------ I was trying to create a recursive function with create_function, but I found a weird problem. When I used the magic constant __FUNCTION__, it returned 'lambda_func', instead of 'lambda_1', the actual result create_function returned. Reproduce code: --------------- <?php $func = create_function ( '$a', 'return is_array ($a)' . "\n" . ' ? array_map (__FUNCTION__, $a)' . "\n" . ' : (is_object ($a)' . "\n" . ' ? (object) array_map (__FUNCTION__, (array) $object)' . "\n" . ' : (is_string ($a)' . "\n" . ' ? htmlspecialchars (str_replace ("\n", \'\n\', $a))' . "\n" . ' : $a));' ); var_dump ($func ('string_var', array ('array_var', 'another_var'))); ?> Expected result: ---------------- array(2) { [0]=> string(9) "array_var" [1]=> string(11) "another_var" } Actual result: -------------- Warning: array_map(): The first argument, '__lambda_func', should be either NULL or a valid callback in /home/jexus/public_html/test/test.php(22) : runtime-created function on line 2 NULL -- Edit bug report at http://bugs.php.net/?id=37915&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37915&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37915&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37915&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37915&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37915&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37915&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37915&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37915&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37915&r=support Expected behavior: http://bugs.php.net/fix.php?id=37915&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37915&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37915&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37915&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37915&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37915&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37915&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37915&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37915&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37915&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37915&r=mysqlcfg