note 106978 deleted from function.create-function by tularis
| From: | tularis@php.net | Date: | Thu, 22 Dec 2011 20:47:26 +0000 |
| Subject: | note 106978 deleted from function.create-function by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185228@lists.php.net to get a copy of this message | ||
Note Submitter: eithed at gmail
Reason: bad code
----
Please bear in mind that create_function has many caveats.
For example consider the following function:
[code]
function check($parameters)
{
return !empty($parameters) ? $parameters : 'empty';
}
[/code]
You cannot create an anonymous function by doing this:
[code]
create_function("$parameters","return !empty($parameters) ? $parameters :
'empty';");
[/code]
as it results in syntax error, unexpected ')'.
In this example create_function has problem with:
- understading ?: operator
- functions with write context
So we have to deal with this:
[code]
create_function("$parameters", "if (sizeof($parameters) > 0) return $parameters;
else return 'empty';");
[/code]