Re: How to define private variable or private function in class
| From: | Gabor Hojtsy | Date: | Sun, 23 Apr 2006 11:54:25 +0000 |
| Subject: | Re: How to define private variable or private function in class | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-31262@lists.php.net to get a copy of this message | ||
Hi Rannk,
Since your problem has nothing to do with webmastering of the php.net
website, it does not belong in here.... Please contact
php-general@lists.php.net (a mailing list) with support questions or see
http://php.net/support for more support options.
BTW the documentation does not say that this is going to be private.
Regards,
Gabor Hojtsy
rannk wrote:
> Hello webmaster!
> I saw the format of defining private variable like "var $_id" in document.But it
> isn't work true. I was instance the class and could add the variable in this defined var.My php
> version is 4.3.6
>
> This is my code.
> <?php
> class TestCode {
> var $a = "bbb";
> var $_id;
>
> function TestCode(){
> $this->_id = "ccc";
> }
>
> function ShowString(){
> echo $this->a."<br>";
> echo $this->_id;
> }
> }
>
> $a = new TestCode;
> $a->a = "aaa";
> $a->_id = "bbb";
>
> $a->ShowString();
> ?>
>
> Output is
> aaa
> bbb
>
>
> I am waiting your answer.
>
>
> rannk
> rannk_deng@hotmail.com
> 2006-04-23