fork download
  1. <?php
  2.  
  3. class A {
  4. function example() {
  5. echo "I am A::example() and provide basic functionality.<br />\n";
  6. }
  7. }
  8.  
  9. class B extends A {
  10. function example() {
  11. echo "I am B::example() and provide additional functionality.<br />\n";
  12. parent::example();
  13. }
  14. }
  15.  
  16. $b = new B;
  17.  
  18. // This will call B::example(), which will in turn call A::example().
  19. $b->example();
  20.  
  21. // Saída:
  22. // I am B::example() and provide additional functionality.
  23. // I am A::example() and provide basic functionality.
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
I am B::example() and provide additional functionality.<br />
I am A::example() and provide basic functionality.<br />