PHP Automatic Properties / Overloading -


I'm writing some PHP, I have several classes that do not declare any property, public or otherwise I have a Custom MySQL class that brings the object from mySQL and sets property value for new init'd PHP objects, such as ...

  while ($ row = mysql_fetch_assoc ($ result)) {Foreign currency ($ line as $ line = & gt; $ value) {$ this- & gt; {$ Key} = $ value; }}  

It works just as I can say that anywhere in virtually anywhere I ... $ this- & gt; My_auto_property etc. I can not find any PhD documents that explain it as a way to overload the properties of class objects.

Is that okay? I want to make sure that this is not some kind of previous compatibility that will disappear in future PHP release.

itemprop = "text">

This is not overloading any asset, it is simply setting up a property using variable variables. Dynamically creating new properties has always been a feature of PHP. Of course, no one can guarantee that he will not be deprecated, but the way PHP supports weak typing, I can say that this is not possible.

An option to store values ​​in an array and make a magic, to read them, if you want to increase your control over encapsulation and access.


Comments