for example one: class a{ private function foo(){ echo this is a test function.
; } public function test(){ $this->foo(); static::foo(); }}$a=new a();$a->test();
输出结果:
this is a test function
this is a test function
for example two: class a{ private function foo(){ echo this is a test function.
; } public function test(){ $this->foo(); static::foo(); }}class b extends a{}$b=new b();$b->test();
输出结果:
this is a test function
this is a test function
for example three: class a{ private function foo(){ echo this is a test function.
; } public function test(){ $this->foo(); static::foo(); }}class b extends a{}class c extends a{ private function foo(){ } } $c=new c();$c->test();
输出结果:
this is a test function
( ! ) fatal error: call to private method c::foo() from context ‘a’ in d:\www\testxdebug\index.php on line 21
call stack
time memory function location
1 0.0156 135536 {main}( ) …\index.php:0
2 0.0156 135936 a->test( ) …\index.php:35
版权声明:本文为博主原创文章,未经博主允许不得转载。