标签:style blog color io ar sp div on cti
class base { private $member; function __construct() { echo __METHOD__ . "(begin)\n"; $this->member = ‘base::member‘; $this->test(); echo __METHOD__ . "(end)\n"; } function test() { echo __METHOD__ . "\n"; print_r($this); } } class derived extends base { public $member = ‘derived::member (default)‘; function __construct() { echo __METHOD__ . "(begin)\n"; parent::__construct(); parent::test(); $this->test(); $this->member = ‘derived::member‘; echo __METHOD__ . "(end)\n"; } function test() { parent::test(); echo __METHOD__ . "\n"; print_r($this); } } $t = new derived(); $t->test(); unset($t);
打印结果为:
1 derived::__construct(begin) 2 base::__construct(begin) 3 base::test 4 derived Object 5 ( 6 [member] => derived::member (default) 7 [member:base:private] => base::member 8 ) 9 derived::test 10 derived Object 11 ( 12 [member] => derived::member (default) 13 [member:base:private] => base::member 14 ) 15 base::__construct(end) 16 base::test 17 derived Object 18 ( 19 [member] => derived::member (default) 20 [member:base:private] => base::member 21 ) 22 base::test 23 derived Object 24 ( 25 [member] => derived::member (default) 26 [member:base:private] => base::member 27 ) 28 derived::test 29 derived Object 30 ( 31 [member] => derived::member (default) 32 [member:base:private] => base::member 33 ) 34 derived::__construct(end) 35 base::test 36 derived Object 37 ( 38 [member] => derived::member 39 [member:base:private] => base::member 40 ) 41 derived::test 42 derived Object 43 ( 44 [member] => derived::member 45 [member:base:private] => base::member 46 ) 47 Done
标签:style blog color io ar sp div on cti
原文地址:http://www.cnblogs.com/hylaz/p/4022776.html