In the previous PHP, we cannot directly operate on the result of an object instantiation: show (); // PHPParseerror: syntaxerror, unexpectedT_OBJECT_OPERATOR. we can only save the instantiation result first, then call :... "> <LINKhref =" http: // ww
In the previous PHP, we cannot directly operate on the result of an object instantiation:
Show (); // PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR
We can only save the instantiation result first and then call:
$ A = new Foo (); $ a-> show ();
Many people have put forward requests for this improvement. However, due to implementation problems, PHP has never been added.
At this point, I will explain that the PHP syntax analysis system is a system with a long history. in this long history, it will not stop repairing and completing, but will more or less cause some specific features. if you want to rewrite it, it takes time and effort, and it is difficult to be fully compatible with the current one, so I want to completely rewrite it, it can only be PHP6. (for the development team, it is announced that PHP6 has stopped development and does not have such a suggestion)
However, if we fix the issue, we will introduce an unsolvable shift-by-contract conflict. I have tried to implement this feature before, but because of this problem, so no submission ..
However, with the increase in requirements for this feature, we gradually feel that even if there is a shift in the near/contract conflict, there is no such thing. hey, so:
Now, this feature is finally supported by Felipe (Instance and method call/property access). now we can write the following syntax:
Bar () (new $ foo ()-> bar (new $ bar-> y)-> x (new foo) [0]
You may have noticed that all instantiation styles need to be enclosed in parentheses. Yes, if not, there will be the following conflicting syntax first:
New $ bar-> y-> x;
In this case, there is a conflict. is it (new $ bar)-> y, or (new $ bar-> y)-> x.
Another reason is because of the current PHP syntax system. if we do not add parentheses, we will introduce more near-moving/reduction conflicts.
But I believe there is nothing in this bracket, at least it looks clearer.
Speaking of this, I am very curious about how many known "shift near/contract" conflicts can be solved in the C ++ syntax analysis, do you know anyone? Haha.
Currently, 5.4RC1 has been released. if you are interested, you can try it out early and test it for PHP :) PHP 5.4RC1 and enjoy!
However, we still need to remind you that PHP 5.4 is still in the development stage. before the final release, any new features may be adjusted or changed. if you have any suggestions, please feel free to give us feedback and help us make PHP better.
Thank you.