How to define private variable or private function in class
| From: | rannk | Date: | Sun, 23 Apr 2006 10:48:35 +0000 |
| Subject: | How to define private variable or private function in class | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-31261@lists.php.net to get a copy of this message | ||
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