Dynamic properties in classes?

28
Nov

I found this blog post on Reddit this morning...

http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/

... discussing dynamic class properties in PHP. Well, as it turns out, PHP by default just lets you do whatever the hell you want with properties, which seems like a bad idea to me, I've always defined getters and setters to access protected properties, but I do like the idea of defining the __set() magic method to throw an exception, to stop any other devs working on the project from utilizing this "feature" of PHP's.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.