I have an object that has private keys like this _errors:private. I am trying to print_r farther down the multidimensional array (to get specific error codes). But when i try the print_r comes up empty. How do I get thous objects?
I have an object that has private keys like this _errors:private . I am
Share
If it is private it means that it cannot be accesed from outside the class. You could writte a “getter”, wich is a function that will return that value. You can think that as a bank vault and a teller. You cannot get your money from the vault yourself, you have to ask the teller (in programming, the getter) to go to te vault and get if to you.
in this example, trying to do
$object->secret_varwill throw and error as it is a private property, but calling$object->secret_var_getter();will get you the private var.