note 62288 deleted from language.oop5.overloading by cmb
| From: | cmb@php.net | Date: | Sun, 18 Aug 2019 08:25:13 +0000 |
| Subject: | note 62288 deleted from language.oop5.overloading by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211900@lists.php.net to get a copy of this message | ||
Note Submitter: Sleepless
----
Yet another way of providing support for read-only properties. Any property that has
"pri_" as a prefix will NOT be returned, period, any other property will be returned
and if it was declared to be "protected" or "private" it will be read-only.
(scope dependent of course)
<?php
function __get($var){
if (property_exists($this,$var) && (strpos($var,"pri_") !== 0) )
return $this->{$var};
else
//Do something
}
?>