note 92818 added to functions.anonymous
| From: | dave at mausner dot us | Date: | Mon, 10 Aug 2009 21:34:35 +0000 |
| Subject: | note 92818 added to functions.anonymous | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159292@lists.php.net to get a copy of this message | ||
Ulderico had it almost right. To avoid confusing the interpreter, when using a simple closure
stored in a $variable, you must invoke the nameless function using the function syntax.
<?php
$helloworld = function(){
return "each hello world is different... ".date("His");
};
echo $helloworld( );
?>
Note the empty actual-parameter list in the "echo". NOW IT WORKS.
----
Server IP: 209.41.74.194
Probable Submitter: 75.24.69.54
----
Manual Page -- http://www.php.net/manual/en/functions.anonymous.php
Edit -- https://master.php.net/note/edit/92818
Del: integrated -- https://master.php.net/note/delete/92818/integrated
Del: useless -- https://master.php.net/note/delete/92818/useless
Del: bad code -- https://master.php.net/note/delete/92818/bad+code
Del: spam -- https://master.php.net/note/delete/92818/spam
Del: non-english -- https://master.php.net/note/delete/92818/non-english
Del: in docs -- https://master.php.net/note/delete/92818/in+docs
Del: other reasons-- https://master.php.net/note/delete/92818
Reject -- https://master.php.net/note/reject/92818
Search -- https://master.php.net/manage/user-notes.php