fork(1) 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. }
  13.  
  14. function main() {
  15. $this->example();
  16. parent::example();
  17. }
  18. }
  19.  
  20. $b = new B;
  21.  
  22. // This will call B::example(), which will in turn call A::example().
  23. $b->main();
  24.  
  25. // SaĆ­da:
  26. // I am B::example() and provide additional functionality.
  27. // 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 />