【发布时间】:2010-04-02 18:17:23
【问题描述】:
我在使用MyClass::function(); 调用方法时遇到问题,不知道为什么。这是一个示例(顺便说一句,我正在使用 Kohana 框架):
class Test_Core
{
public $var1 = "lots of testing";
public function output()
{
$print_out = $this->var1;
echo $print_out;
}
}
我尝试使用以下方法调用它,但它返回 $var1 为未定义:
Test::output()
但是,这很好用:
$test = new Test();
$test->output();
我通常使用这种调用对象的风格,而不是“新类”风格,但我不知道为什么它不想工作。
【问题讨论】:
-
我不知道为什么,但大部分脚本没有出现在代码部分。当我预览它时,它看起来很好。