Home  >  Article  >  php教程  >  php 魔术方法应用场景简介

php 魔术方法应用场景简介

WBOY
WBOYOriginal
2016-06-06 20:14:472141browse

__construct()对象初始化的时候 __destruct()对象被销毁时 __clone()当对象被clone时 __call()对象中调用一个不可访问的方法时 __callStatic() 以静态方式调用对象中一个不可访问的方法时 __get()读取不可访问的属性 __set()给不可访问的属性复制 __isset()

__construct() 对象初始化的时候

__destruct() 对象被销毁时

__clone() 当对象被clone时

__call() 对象中调用一个不可访问的方法时

__callStatic()

以静态方式调用对象中一个不可访问的方法时

__get() 读取不可访问的属性

__set() 给不可访问的属性复制

__isset() 对不可访问的属性调用isset(),empty()时

__unset() 对不可访问的属性调用unset()时

__sleep() 对对象调用serialize()时

__wakeup() 对对象调用unserialize()时

__set_state() 对对象调用var_export()时

_debugInfo() 对对象调用var_dump()时

__toString() 当尝试以字符串调用对象时

__invoke() 当尝试以调用函数的方式调用对象时

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn