• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why i can access "protected property of model" in controller directly in codeigniter4

#1
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.
Reply

#2
That’s because of the “magic” __get() function that return the property if it exists:

PHP Code:
if (property_exists($this$name))
{
    return 
$this->{$name};

Test your translation files with Translation Tester
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.