PHP头条
热点:

PHP的魔术方法(简介),php魔术方法简介


public void _set(string $name,mixed $value)

public mixed _get(string $name)

public bool _isset(string $name)

public void _unset(string $name)

public mixed _call(string $name,array $arguments)

这些方法的作用如下:

_set(string $name,mixed $value):在对象给未定义或者不可见的属性赋值时被调用,参数name即为需要赋值的属性,value即为需要为属性赋的值。

_get(string $name):在对象访问未定义或者不可见的属性时被调用,参数name即为需要访问的属性名。

_isset(string $name):对未定义或者不可见的属性使用isset()时被调用,参数name即为属性名。

_unset(string $name):对未定义或者不可见的属性使用unset()时被调用,参数name即为属性名。

_call(string $name,array $arguments):在对象调用未定义或不可见的方法时被调用,参数name即为方法名,参数arguments为要传递给方法的参数组成的数组。

注意:这些模式方法的作用就是拦截到访问不存在的对象成员的操作,然后对其做相应的响应,并且这些方法都必须使用public修饰。

 

www.phpzy.comtrue/php/36414.htmlTechArticlePHP的魔术方法(简介),php魔术方法简介 public void _set(string $name,mixed $value) public mixed _get(string $name) public bool _isset(string $name) public void _unset(string $name) public mixed _call(string $name,array $argu...

相关文章

PHP之友评论

今天推荐