note 62288 modified in language.oop5.overloading by danbrown

From: Date: Fri, 14 Nov 2008 17:18:11 +0000
Subject: note 62288 modified in language.oop5.overloading by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146547@lists.php.net to get a copy of this message
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 } ?> --was-- 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) function __get($var){ if (property_exists($this,$var) && (strpos($var,"pri_") !== 0) ) return $this->{$var}; else //Do something } http://php.net/manual/en/language.oop5.overloading.php

« previous php.notes (#146547) next »