PHP 将所有以 __(两个下划线)开头的类方法保留为魔术方法。所以在定义类方法时,除了上述魔术方法,建议不要以 __ 为前缀,除非是为了重载已有的魔术方法。
PHP中的魔术方法有 :
__get(), __set() ,__sleep(), __wakeup(),__construct(), __destruct(),__serialize(), __unserialize(),__isset(), __unset(), __call(), __callStatic(), __toString(), __invoke(), __set_state(), __clone() , __debugInfo(), __autoload()
1、__get、__set