note 49631 added to language.oop5.constants
| From: | douglass_davis at earthlink dot net | Date: | Thu, 03 Feb 2005 12:34:19 +0000 |
| Subject: | note 49631 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84431@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/language.oop5.constants.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49631
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49631&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49631&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49631&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49631&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49631&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49631&report=yes
Search -- http://master.php.net/manage/user-notes.php