fork download
  1. <?php
  2.  
  3. class A
  4. {
  5. function __construct($dataA = false) {
  6. echo "constructor A enter data = $dataA\n";
  7. $dataA .= "A";
  8. echo "constructor A exit data = $dataA\n";
  9.  
  10. return $dataA;
  11. }
  12.  
  13. }
  14.  
  15. class B extends A
  16. {
  17. function __construct($data = false) {
  18. echo "constructor B enter data = $data\n";
  19. $dataB = parent::__construct($data);
  20. $dataB .= "B";
  21. echo "constructor B exit data = $dataB\n";
  22. return $dataB;
  23. }
  24.  
  25. }
  26.  
  27. class C extends B {
  28. function __construct($data = false){
  29. echo "constructor C enter data = $data\n";
  30. $dataC = parent::__construct($data);
  31. $dataC .= "C";
  32. echo "constructor C exit data = $dataC\n";
  33. $this->temp = $dataC;
  34. }
  35. }
  36.  
  37. $c = new C("D");
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
constructor C enter data = D
constructor B enter data = D
constructor A enter data = D
constructor A exit data = DA
constructor B exit data = DAB
constructor C exit data = DABC
object(C)#1 (1) {
  ["temp"]=>
  string(4) "DABC"
}