class Test{ public $username='king'; protected $money=123456.89; private $age=12; public $test1='this is a test1'; public function __toString(){ echo '当输出对象的时候...我才自动调用<br/>'; return 'hello object'; } private function testPrivate(){ echo 'this is private func<br/>'; } public function __invoke(){ print_r(func_get_args()); echo '当以调用函数的方式调用对象的时候,会自动触发这个方法...<br/>'; } public function __call($methodName,$args){ echo '__call methodName:'.$methodName.'<br/>'; print_r($args); } private static function testPrivateStatic(){ echo 'this is a private Static function...<br/>'; } public static function __callStatic($methodName,$args){ echo '__callStatic StaticMethodName:'.$methodName.'<br/>'; print_r($args); } public function __sleep(){ echo '对象被序列化了...<br/>'; return array('username','age'); } public function __wakeup(){ echo '反序列化得时候自动调用...<br/>'; $this->username='queen'; echo $this->username.'<br/>'; } } $test=new Test; // echo $test; //$test(10,20,30,'test'); //echo '<br/>'; //$test->noExists(1,2,3,4,5); //echo '<hr/>'; //$test->testPrivate(); //echo '<hr/>'; //Test::testPrivateStatic(123123); //echo '<hr/>'; //Test::noExistsStatic();