1. <?php
  2. /**
  3. * this is a test
  4. */
  5. class A
  6. {
  7. private function _foo()
  8. {
  9. echo "success!<br>";
  10. }
  11. public function __construct()
  12. {
  13. }
  14. public function test()
  15. {
  16. $this->_foo();
  17. static::_foo();
  18. }
  19. }
  20. /**
  21. * this is B
  22. */
  23. class B extends A
  24. {
  25. public function __construct()
  26. {
  27. }
  28. }
  29. /**
  30. * this is c
  31. */
  32. class C extends A
  33. {
  34. public function __construct()
  35. {
  36. }
  37. private function _foo()
  38. {
  39. echo "can not access!";
  40. }
  41. }
  42. $b = new B();
  43. $b->test();
  44. $c = new C();
  45. $c->test();

分类: web

标签:   php