面向对象

<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();

?>

posted @ 2014-05-21 23:02  往昔-安安  阅读(103)  评论(0编辑  收藏  举报