note 49631 deleted from language.oop5.constants by danbrown

From: Date: Wed, 03 Aug 2011 13:30:34 +0000
Subject: note 49631 deleted from language.oop5.constants by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182184@lists.php.net to get a copy of this message
Note Submitter: douglass_davis at earthlink dot net ---- Re: caliban at darklock dot com most people are not going to do all of this: <?php if(isset($y["@$classname@$b"])) echo "\"$b\" is private: {$y["@$classname@$b"]}<br/>"; ?> to read an object variable. My point is: what you said is true, however access specifiers do have an effect on who gets to read the variables when you are not trying to bypass encapsulation: <?php class Foo { private $varname=2; } $obj=new Foo(); echo $obj->varname; // accessing in the usual way doesn't work ?> So: const gives you a constant that is public in terms of reading them the usual way. A private const would mean you could not read the variable using the 2nd method above. Not to say it's an "omission in PHP," but, realize that there would be some value added in allowing consts to be made private.

« previous php.notes (#182184) next »