mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fix #72331: most simple way to call anonymous function assigned to object property missing
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@339308 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
ec6a5fb91f
commit
06df50f0b1
1 changed files with 7 additions and 1 deletions
|
@ -263,7 +263,8 @@ method
|
|||
That means that calling an <link linkend="functions.anonymous">anonymous
|
||||
function</link> which has been assigned to a property is not directly
|
||||
possible. Instead the property has to be assigned to a variable first, for
|
||||
instance.
|
||||
instance. As of PHP 7.0.0 it is possible to call such a property directly
|
||||
by enclosing it in parentheses.
|
||||
</para>
|
||||
<example>
|
||||
<title>Calling an anonymous function stored in a property</title>
|
||||
|
@ -281,8 +282,13 @@ class Foo
|
|||
}
|
||||
|
||||
$obj = new Foo();
|
||||
|
||||
// as of PHP 5.3.0:
|
||||
$func = $obj->bar;
|
||||
echo $func(), PHP_EOL;
|
||||
|
||||
// alternatively, as of PHP 7.0.0:
|
||||
echo ($obj->bar)(), PHP_EOL;
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
|
|
Loading…
Reference in a new issue