Home

Dynamic properties in classes?

by Cameron

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

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

... 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.

November28

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
8 + 12 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.