diff --git a/language/oop5/basic.xml b/language/oop5/basic.xml index 6f5ec49429..aa56c33116 100644 --- a/language/oop5/basic.xml +++ b/language/oop5/basic.xml @@ -263,7 +263,8 @@ method That means that calling an anonymous function 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. Calling an anonymous function stored in a property @@ -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; ]]> &example.outputs;