fork download
  1. <?php
  2. class Test {
  3.  
  4. private $name;
  5.  
  6. public function __construct($name) {
  7. $this->name = $name;
  8. }
  9.  
  10. public function getName() {
  11. return $this->name;
  12. }
  13.  
  14. }
  15.  
  16. class Testb extends Test {
  17.  
  18. public function __construct($name) {
  19. parent::__construct($name);
  20. }
  21.  
  22. }
  23.  
  24. $a = new Test('John');
  25. $b = new Testb('Batman');
  26.  
  27. echo $a->getName();
  28. echo $b->getName();
  29. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
JohnBatman