【发布时间】:2017-07-27 07:15:09
【问题描述】:
考虑下面的代码,我正在使用 codeigniter 3.0
Xmodel.php
---------------------
class Xmodel {
public static function get(){
}
}
Ymodel.php
------------------------
class Ymodel(){
public function run(){
$this->load->model('XModel', 'x');
$this->x::get(); // syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)
$this->x->get(); // works as expected
}
}
我怀疑get() 是否是静态方法,那么为什么它不能与:: 运算符一起使用。作为参考What does this mean? "Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM" 在这个问题中,该方法也是静态的,但他们没有证明为什么他们使用-> 作为静态方法。非常感谢任何帮助。
【问题讨论】:
标签: php codeigniter