![]() |
why i can access "protected property of model" in controller directly in codeigniter4 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: why i can access "protected property of model" in controller directly in codeigniter4 (/showthread.php?tid=75837) |
why i can access "protected property of model" in controller directly in codeigniter4 - sandip002 - 03-22-2020 Today, I'm playing with Codeigniter 4 and create a crud application. But when I access "MODELS PROTECTED PROPERTIES" directly in the controller it gives me data on why it will not giving any error. example: when I try to access " protected $validationRules " property of model it will return array of rules. I'm not using the " public getValidationRules() " method I'm directly accessing the property and it gives me data. RE: why i can access "protected property of model" in controller directly in codeigniter4 - includebeer - 03-22-2020 That’s because of the “magic” __get() function that return the property if it exists: PHP Code: if (property_exists($this, $name)) |