How to implement a read-only member variable in PHP?
When trying to change it,throw an exception. I suppose a solution, for class properties, would be to : not define a property with the name that interests you use the magic __get method to access that property, using the "fake" name define the __set method so it throws an exception when trying to set that property. See Overloading , for more informations on magic methods. For variables, I don't think it's possible to have a read-only variable for which PHP will throw an exception when you're trying to write to it. For instance, consider this little class : class MyClass { protected $_data =