Bug #52968 [Bgs]: Static private attributes visibility
| From: | rasmus@php.net | Date: | Sun, 03 Oct 2010 04:05:48 +0000 |
| Subject: | Bug #52968 [Bgs]: Static private attributes visibility | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154851@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52968&edit=1
ID: 52968
Updated by: rasmus@php.net
Reported by: czambran at csrg dot inf dot utfsm dot cl
Summary: Static private attributes visibility
Status: Bogus
Type: Bug
Package: Class/Object related
Operating System: Linux/Ubuntu Lucid Lynx
PHP Version: Irrelevant
Block user comment: N
New Comment:
No it doesn't, and your code shows it doesn't let it. You said your
expected
result was for it to show 15, and it didn't.
Previous Comments:
------------------------------------------------------------------------
[2010-10-03 06:02:00] czambran at csrg dot inf dot utfsm dot cl
[2010-10-02 06:16 UTC] rasmus@php.net
That's what private means. You are not allowed to access it from
outside of the
class. You can make a static accessor method in your Device class that
returns
it, if you like.
-----
Because that, the problem is that php is allowing to access it from
outside, without the using of the static accessor method :P.
Greetings
------------------------------------------------------------------------
[2010-10-02 10:48:16] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=303931
Log: - Substantially improved the documentation of strtr(). Closes bug
#52968.
------------------------------------------------------------------------
[2010-10-02 08:16:35] rasmus@php.net
That's what private means. You are not allowed to access it from
outside of the
class. You can make a static accessor method in your Device class that
returns
it, if you like.
------------------------------------------------------------------------
[2010-10-02 08:07:37] czambran at csrg dot inf dot utfsm dot cl
Description:
------------
Static private attributes of a class can be directly by another
non-friendly resource or file.
Test script:
---------------
If I define a class with static methods, as the following:
class Device{
static private $id = 15;
}
For example, if the class Device is stored into device.class.php and I
have another file called main.php and the implementation of main.php is
the following:
<?php
include("device.class.php");
echo "The device's id is: ".Device::$id;
?>
Expected result:
----------------
The device's id is 15.
Actual result:
--------------
Not relevant results yet.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52968&edit=1