I defined a class User and declared a method getName() of the class. Why does an error appear when I use $user=new User;$name=$user.getName()? -PHP Chinese website Q&A-I defined a class User and declared a method getName() of the class. Why does it report an error when I use $user=new User;$name=$user.getName()? -PHP Chinese website Q&A
I defined a class User and declared a method getName() of the class. Why does an error appear when I use $user=new User;$name=$user.getName()? -PHP Chinese website Q&A-I defined a class User and declared a method getName() of the class. Why does it report an error when I use $user=new User;$name=$user.getName()? -PHP Chinese website Q&A
Let’s take a look and learn.
注意php中对类成员的引用方式,上面的引用应该为$name=$user->getName(),即使用->符号,而不是
Java中使用的“.”号。