在我提出问题之前,我想说我搜索过这个问题,并且其他答案都没有帮助......
基本上,在我的类DemoClass
中,我有4个函数,并且它们都是“未定义的属性”
我的错误:
Notice: Undefined property: DemoClass::$function in /home/content/92/10270192/html/class.php on line 46
注意:第 46 行是我执行 $demoClass->function... 的地方
我有一个典型的类(class)设置:
class DemoClass {
public function __construct () {
// stuff that works and gets called
}
public function testFunct () {
// one that is an "undefined property"
}
}
我正常访问类(class):
$testClass = new DemoClass();
var_dump(testClass->testFunct); // this is what is on line 46
// ^^^ This also gives me NULL, because its undefined (? i guess...)
我以前从未遇到过这个问题,有什么建议吗?谢谢!
最佳答案
调用函数时需要括号。将其更改为 $testClass->testFunct()
。
关于PHP 类;通知: Undefined property error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21083808/