我对OOP很陌生,在PHP上很生疏。我想知道这是否是从类调用函数的有效方法?类中的PHP调用函数 - 有没有更简单的方法?
class newclass {
public function testfunc {
return '1';
}
}
我可以这样称呼它:
echo testfunc->newclass();
或像这样:
echo newclass()::testfunc;
我总是看到它实施例中定义如下图所示,它似乎是额外的代码?:
$this = new newclass();
$this->testfunc();
echo $this;
任何帮助将grea因为我刚刚开始围绕这个面向对象的事情而感到欣慰。如果我外出吃午饭,也许有人可能会建议一个真正的好的指导,为一个真正的初学者在课堂/面向对象的链接。谢谢!
http://php.net/manual/en/language.oop5.php – NullUserException