KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 echo $objObject->arrArray[0]; 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: $arrArray = $objObject->getArray1(); echo $arrArray[0]; And anyways, while it keeps the array in the object pristine, it doesn't prevent me from re-writing the local array variable.
Tags (comma-separated)
Save Edits
Cancel