PHP magic functions
Class Person {private $ name; private $ age; private $ sex; public function _ construct ($ name, $ age, $ sex) {$ this-> name = $ name; $ this-> age = $ age; $ this-> sex = $ sex;} public function _ get ($ property) {if (isset ($ this-> $ property) {return $ this-> $ property;} else {return null ;}} public function _ set ($ property, $ value) {$ this-> $ property = $ value;} // when the isset () function is used outside the class to determine the private member $ nm, automatically call public function _ isset ($ property) {return isset ($ this-> $ property);} // When unset () is used outside the class () public function _ unset ($ property) {unset ($ this-> $ property );} // automatically call _ toString () public function _ toString () {return "hello world" when the echo object name is directly called outside the object "."
";} // Automatically call _ clone () public function _ clone () when calling clone outside the object () {$ this-> name = "I am clone object";} // when no methods or parameters exist in the object's external call, an error is returned, automatically call the _ call function public function _ call ($ function_name, $ args) {print "Your called function: $ function_name (parameter:"; print_r ($ args ); print ") does not exist!
\ N ";}// serialize automatically calls _ sleep () public function _ sleep () When serializing the object () {}// when the object is deserialized, the unserialize automatically calls the wakeup () public function _ wakeup () {}} function _ autoload ($ classname) {require_once ($ classname. ". php ");}