Link PHP class from a variable with access to a static method

Gives an error:

$this->model::byUserPermission() Leads to: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) 

Works:

 $facade = $this->model; $facade::byUserPermission() 

Is this a PHP bug? Or can someone explain this to me why this happens (I am using php 5.6 and I am new to php. From my point of view, both of them are exactly the same). Thanks

+6
source share
1 answer

The problem is that this $this->model::byUserPermission() ambiguous. And can be interpreted in several ways.

1) You can try to use the model property of the class you are in to call the static method of the class. How are you trying in your question.

2) You can also say that you want to access the property of the class returned by the static function byUserPermission() in the class model .

+2
source

All Articles