ID: 37915
Updated by: [EMAIL PROTECTED]
Reported By: jexus at jexus dot net
-Status: Open
+Status: Wont fix
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.1.4
New Comment:
Constant __FUNCTION__ is resolved during compile time, while lambda
functions are created in runtime, so the constant value is correct.
I don't think anybody is going to change it ever.
Previous Comments:
------------------------------------------------------------------------
[2006-06-26 11:56:36] jexus at jexus dot net
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 this bug report at http://bugs.php.net/?id=37915&edit=1