php: avoiding __get in certain circumstances?

Posted by user151841 on Stack Overflow See other posts from Stack Overflow or by user151841
Published on 2010-03-18T17:11:56Z Indexed on 2010/03/18 17:31 UTC
Read the original article Hit count: 119

Filed under:
|
|

I have a class where I'm using __set. Because I don't want it to set just anything, I have an array of approved variables that it checks before it will actually set a class property.

However, on construct, I want the __construct method to set several class properties, some of which are not in the approved list. So when construct happens, and I do $this->var = $value, I of course get my exception that I'm not allowed to set that variable.

Can I get around this somehow?

© Stack Overflow or respective owner

Related posts about php

Related posts about magic-methods