read-only properties in PHP?

dontcare

New Member
Is there a way to make a read-only property of an object in PHP? I have an object with a couple arrays in it. I want to access them as I normally would an array \[code\]echo $objObject->arrArray[0];\[/code\]But I don't want to be able to write to those arrays after they're constructed. It feels like a PITA to construct a local variable:\[code\]$arrArray = $objObject->getArray1();echo $arrArray[0];\[/code\]And anyways, while it keeps the array in the object pristine, it doesn't prevent me from re-writing the local array variable.
 
Back
Top