由于你可以用而不是使用$ this->在一个静态函数中,你应该如何访问静态内部的常规函数?访问一个静态函数内的公共/私人函数?
private function hey()
{
return 'hello';
}
public final static function get()
{
return $this->hey();
}
此抛出一个错误,因为你不能使用$这 - >内静态。
private function hey()
{
return 'hello';
}
public final static function get()
{
return self::hey();
}
这引发以下错误:
Non-static method Vote::get() should not be called statically
你怎么能访问静态方法中常用数据处理方法?在同一类*
如果要调用它们,则必须将不会访问'$ this'的函数更改为静态函数。 – 2013-05-07 21:01:11
将类引用传递给您的静态方法。 – 2013-05-07 21:02:04
我该怎么做?就像在hey()中那样,返回$ this-> get(“hello”)? – 2013-05-07 21:04:17