1.属性重载类方法
(重载类方法不能被声明为static)
__set
解释:在给不可访问属性赋值时,__set() 会被调用。
使用:public __set ( string $name , mixed $value ) : void
传入属性名和属性值,无返回值
__get
解释:读取不可访问属性的值时,__get() 会被调用。
使用:public __get ( string $name ) : mixed
传入属性名,返回属性值
__isset
解释:当对不可访问属性调用 isset() 或 empty() 时,__isset() 会被调用。
使用:public __isset ( string $name ) : bool
传入属性名,返回布尔值
__unset
解释:当对不可访问属性调用 unset() 时,__unset() 会被调用。
使用:public __unset ( string $name ) : void
传入属性名,无返回值
2.方法重载类方法
__call
解释:在对象中调用一个不可访问方法时,__call() 会被调用。
使用:public __call ( string $name , array $arguments ) : mixed
传入方法名和参数数组,返回mixed类型
__callStatic
解释:在静态上下文中调用一个不可访问方法时,__callStatic() 会被调用。
使用:public static __callStatic ( string $name , array $arguments ) : mixed
传入方法名和参数数组,返回mixed类型
参考资料:https://www.php.net/manual/zh/language.oop5.overloading.php