Blogger Information
Blog 28
fans 1
comment 0
visits 17346
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
2019.6.13作业
关超的博客
Original
626 people have browsed it

6月13日作业

  1. 编写一个类,例如学生类,商品类, 体会private, protected, public的作用


class Student

{

    public $name; 

    public $age; 

    private $sex;    

     public function __construct($name, $age, $sex)

    {

        $this->name = $name;

        $this->age = $age;

        $this->sex= $sex;

    }


    public function getSex(){

        return $this->sex

    }

}


$student= new Student('chao','30','男');

echo $student->name, '<br>';

echo $student->age, '<br>';

echo $student->getSex();


  1.  实例演示类的继承环境中, 对封装成员访问的权限控制技术,要求用到protected, extends, 以及获取器方法



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post