calling a method of an object at instance creation

前端 未结 5 1011
[愿得一人]
[愿得一人] 2020-12-19 18:08

In PHP why can\'t I do:

class C
{
   function foo() {}
}

new C()->foo();

but I must do:

$v = new C();
$v->foo();
         


        
5条回答
提交回复
热议问题