|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-06-26 12:07 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 09:00:01 2025 UTC |
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