As you might have seen in the title, my programming background is Java. In Java you can do stuff like this
new Object().callSomeMethod();
without assigning the created Object to a variable, very useful and clear coding if you only need this Object once.
Now in PHP i try to do the same
new Object()->callSomeMethod();
but here i get a 'Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)'.
Is there a way to do this in PHP ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…