<meta http-equiv="Content-Type"
content="text/html;charset=UTF-8"/>
<?php
class Person{
private $name;
private $pwd;
private $age;
//在初始化对象的时候该函数会自动运行
//初始化函数
function
__construct($name,$pwd,$age){
$this->name = $name;
$this->pwd = $pwd;
$this->age = $age;
}
public function intro(){
echo "我的名字是:".$this->name."
我的密码是:".$this->pwd;
}
}
$p1 = new Person("zhangsan","sssss",20);
$p1->intro();
?>
原文:http://www.cnblogs.com/ZH1132672711/p/3744073.html