<?
php class Test{
public $name='Janking',
$sex='male',
$age=23;
function __construct(){
echo $this->age.'<br />'.$this->name.'<br />'.$this->sex.'<br />';
}
function func(){
echo $this->age.'<br />'.$this->name.'<br />'.$this->sex.'<br />';
}
}
$P=new Test();
echo '<br /><br />';
$P->age=100;
$P->name="Rainy";
$P->sex="female";
$P->func();
?>
Public
<?
php class Test{
private $name='Janking',
$sex='male',
$age=23;
function __construct(){
$this->funcOne();
}
function func(){
echo $this->age.'<br />'.$this->name.'<br />'.$this->sex.'<br />';
}
private function funcOne(){
echo $this->age.'<br />'.$this->name.'<br />'.$this->sex.'<br />';
}
}
$P=new Test();
echo '<br /><br />';
$P->func();
$P->age=100; // Cannot
access private property Test::$age
$P->name="Rainy"; // Cannot access private property Test::$name
$P->sex="female"; // Cannot access private property Test::$female
$P->funcOne(); // Call to private method Test::funcOne() from context ''
?>
Private