note 113637 added to functions.anonymous
| From: | assarte dot draven at gmail dot com | Date: | Fri, 08 Nov 2013 08:51:49 +0000 |
| Subject: | note 113637 added to functions.anonymous | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197463@lists.php.net to get a copy of this message | ||
You cannot use closures as a class variable member in its declaration like this:
<?php
class foo
{
public $bar = function() {
echo "baz";
};
}
?>
I don't know why but this will raise a
Parse error: syntax error, unexpected 'function' (T_FUNCTION)
(used PHP 5.4)
----
Server IP: 64.71.164.2
Probable Submitter: 178.164.255.135
----
Manual Page -- http://php.net/manual/en/functions.anonymous.php
Edit -- https://master.php.net/note/edit/113637
Del: integrated -- https://master.php.net/note/delete/113637/integrated
Del: useless -- https://master.php.net/note/delete/113637/useless
Del: bad code -- https://master.php.net/note/delete/113637/bad+code
Del: spam -- https://master.php.net/note/delete/113637/spam
Del: non-english -- https://master.php.net/note/delete/113637/non-english
Del: in docs -- https://master.php.net/note/delete/113637/in+docs
Del: other reasons-- https://master.php.net/note/delete/113637
Reject -- https://master.php.net/note/reject/113637
Search -- https://master.php.net/manage/user-notes.php