southbeach
Programmer
So, I read an article that says that one should "never" directly invoke the value of a class object/variable like so
but rather have a method in the class and use the method to invoke the variable
and you will then call it like so
Frankly, this looks like a big waste and seems like bloated coding. I love using classes to retrieve MySQL data from tables and fill forms/values and I have gotten my own approach that works for me ...
Now, security is something I take seriously and if using classes and invoking its variables ($object->variable) is risky, I will change my ways but hell, I really want to know if this is as bad as the guy in the article made it sound.
NOTE: I tried to dig up the article again to provide you guys the link but I just cannot find it.
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
Code:
echo $object->variable;
but rather have a method in the class and use the method to invoke the variable
Code:
function getValue($varName) {
return(this->$varName);
}
and you will then call it like so
Code:
echo $object->getValue('variable');
Frankly, this looks like a big waste and seems like bloated coding. I love using classes to retrieve MySQL data from tables and fill forms/values and I have gotten my own approach that works for me ...
Now, security is something I take seriously and if using classes and invoking its variables ($object->variable) is risky, I will change my ways but hell, I really want to know if this is as bad as the guy in the article made it sound.
NOTE: I tried to dig up the article again to provide you guys the link but I just cannot find it.
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.