我不明白为什么以下不适合我。我复制了我的一些教程中,但在运行程序时,我得到一个错误:php:在构造函数中访问类变量
class tc {
private $test = NULL;
public function __construct(){
$this->$test = 'sdfsdf';
}
}
创建对象:
$test = new tc;
Undefined variable: test
Cannot access empty property..
我知道这是很基本的,但不明白是什么我做错了。
尝试'$ this-> test'(正如Abra指出的那样)。我看到它之前评论。 – Dutchie432
另外,也许不要使用这些教程:-) – AbraCadaver