Blogger Information
Blog 53
fans 3
comment 0
visits 46725
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
类与对象-第九期线上班
emagic
Original
747 people have browsed it

11月26日作业:

1. 创建类、实例化、命名空间、类成员、类方法(手写)

2. 构造方法

  1. class A{
  2. public $name;
  3. public $age;
  4. // 构造方法有什么用,可以接受传值,在实例化时就传值
  5. public function __construct($name,$age){
  6. // 在类里面如何访问类成员?用$this->
  7. $this -> name=$name;
  8. $this -> age=$age;
  9. echo $this -> name.$this -> age;
  10. }
  11. }
  12. $a= new A('猴子','3岁');
  13. echo '<hr>';
  14. $a= new A('兔子','1岁');

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:恭喜你,入门了
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