今日课程:PHP开发-零基础到精通疯狂实战教程(第二季)【韦玮老师】php
课程接昨日课程ide
/*访问成员方法*/ $b ->b();
一、对象和成员访问函数
/*$this*/ class c{ var $name ;//常规属性 private $heigh;//私有属性 public $weigh;//公有属性 static $age;//静态属性 function b(){//方法用函数声明 echo "i can eat!<br>"; } function d(){ echo "My name is:".($this -> name).'<br>'; $this -> b(); } } $p = new c(); $p -> name ="da"; $p ->d();
/*构造方法和析构方法*/ class e{ var $name ;//常规属性 private $heigh;//私有属性 public $weigh;//公有属性 static $age;//静态属性 function b(){//方法用函数声明 echo "i can eat!<br>"; } function d(){ echo "My name is:".($this -> name).'<br>'; $this -> b(); } function __construct(){//构造方法 echo "i am gouzao<br>"; } function __destruct(){//析构方法 echo "i am xigou"; } } $q = new e(); //$q -> e(); $q -> d();