note 106978 added to function.create-function
| From: | eithedatgmail at osu1 dot php dot net | Date: | Thu, 22 Dec 2011 15:16:02 +0000 |
| Subject: | note 106978 added to function.create-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185208@lists.php.net to get a copy of this message | ||
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]
----
Server IP: 69.147.83.197
Probable Submitter: 213.123.125.132
----
Manual Page -- http://www.php.net/manual/en/function.create-function.php
Edit -- https://master.php.net/note/edit/106978
Del: integrated -- https://master.php.net/note/delete/106978/integrated
Del: useless -- https://master.php.net/note/delete/106978/useless
Del: bad code -- https://master.php.net/note/delete/106978/bad+code
Del: spam -- https://master.php.net/note/delete/106978/spam
Del: non-english -- https://master.php.net/note/delete/106978/non-english
Del: in docs -- https://master.php.net/note/delete/106978/in+docs
Del: other reasons-- https://master.php.net/note/delete/106978
Reject -- https://master.php.net/note/reject/106978
Search -- https://master.php.net/manage/user-notes.php