|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-09-06 01:35 UTC] aharvey@php.net
[2012-09-06 01:35 UTC] aharvey@php.net
-Package: Documentation problem
+Package: Scripting Engine problem
[2017-10-17 12:27 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2017-10-17 12:27 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 18:00:01 2025 UTC |
Description: ------------ This is more than a feature than a bug. Usage of '{}' is not unified at all. Why this syntax: $this->{'function'}; works, but: {'function'}(); doesn't? It's really confusing. In "test script" form i am giving you full example of it. Test script: --------------- <?php function myFunction(){}; // {'myFunction'}(); // doesn't work $str = 'myFunction'; $str(); // works class myClass { public $bar = 'myClass'; public $test = 'myClass'; public function foo() { } } // $class = new {'myClass'}(); // doesn't work $str = "myClass"; $class = new $str(); // works $class->{'foo'}(); // works // $class2 = new {$class->test}; // doesn't work $class2 = new $class->test(); // works Expected result: ---------------- syntax {'myFunction'}(); should work syntax $class = new {'myClass'}(); should work syntax $class2 = new {$class->test}; should work Actual result: -------------- only calling methods and getting properties of class works in that way.