Magic method __set won't be called for protected variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a series of properties set as protected in my class which I meant to have them accessed externally through __set and __get. Unfortunately, it seems that since the properties do exist, the magic methods don't get called, but then I get an error "Cannot access protected property xxxxx", which I didn't meant to access directly, that's what I put the __set and __get magic methods there.

There is no problem if the variable has another name than the external property, if I use $obj->something and the variable is declared protected $_something, the magic methods are called, but then I have different 'external' names than the 'internal' ones, something which I wanted to avoid.

Since I want to have them with the same name, I might declare the variables public, but I wanted to use the magic methods to validate the values assigned to these variables.

Any ideas?

Thanks

Satyam

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux