关于php中self与this parent关键字的用法

$this  //代表本对象

self    //代表  本类

parent   //代表  父类

$this-> 在类中访问实例化后的方法和属性
self::访问类本身中的静态方法和属性 * public static function fun(){}
parent::当前类为子类的时候 用来访问父对象的 静态方法和属性    魔术方法



猜你喜欢

转载自blog.51cto.com/hudamao/2107349