Consider below code, Iam using 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
}
}
I have a doubt if get()
is a static method then why it is not working with ::
operator. As a reference What does this mean? "Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM" In this question also the method is static but they did not justify why they used ->
for static method. Any help is greatly appreciated.
Answer
class Ymodel(){
public function run(){
$this->load->model('XModel', 'x');
$a = $this->x; // save to a var
$a::get(); // works as expected
}
}
https://stackoverflow.com/a/11520244/3205479 This saved me. Hope some one do not suffer again with this kind of php bug.
No comments:
Post a Comment