note 62863 deleted from language.oop5 by mazzanet
| From: | mazzanet@php.net | Date: | Sat, 11 Mar 2006 06:34:35 +0000 |
| Subject: | note 62863 deleted from language.oop5 by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-105263@lists.php.net to get a copy of this message | ||
Note Submitter: dongrikin at gmail dot com
Reason: non-english
----
PHP5 ã¢ã¯ã»ã¹ä¿®é£¾å
<?php
$test = new Test();
echo $test->name; //Prints [king]
echo $test->age; //Prints [Fatal error: Cannot access private property Test::$age ]
echo $test->getAge(); //Prints [20]
echo $test->getName(); //Prints [Fatal error: Call to private method Test::getName() ]
echo $test->setAge($test->getAge()+10);
echo $test->getAge(); //Prints [30]
class Test{
var $name="king";
private $age = 20;
public function getAge(){
return $this->age;
}
public function setAge($i){
$this->age=$i;
}
private function getName(){
return $this->name;
}
}
?>