php - Difference between protected $_mdl and protected $mdl -


this question has answer here:

i have seen people use underscore before variable if use keyword protected e.g.

class administration extends backend_controller {      protected $_mdl = 'model_comments';      function __construct()     {          parent::__construct();          $mdl = $this->_mdl;          $this->load->model($mdl);     }      ...  } 

is underscore needed if use protected before variable?

what benefit of using underscore before mdl like: $_mdl instead of $mdl?

i not in "security" issues, explanation appreciated.

this naming convention. used show scope of property. whether protected or public. seeing underscore know how can access class property.

kind of, (but not really), how __ used magic methods such constructor method.

php not care if follow convention or not. has no impact on how code interpreted.

in other languages you'll see things hungarian notation.

finally, no real security implication. readability of code.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -