fork(2) download
  1. <?php
  2.  
  3. abstract class ParentClass {
  4. private $parentName;
  5.  
  6. public function __construct($name) {
  7. $this->parentName = $name;
  8. }
  9.  
  10.  
  11. public function getParentName() {
  12. return $this->parentName;
  13. }
  14.  
  15. }
  16.  
  17. class ChildClass extends ParentClass {
  18.  
  19. }
  20.  
  21.  
  22.  
  23. $b = new ChildClass('joj');
  24.  
  25.  
  26.  
  27. echo $b->getParentName();
  28.  
  29.  
Success #stdin #stdout 0.04s 82880KB
stdin
Standard input is empty
stdout
object(ChildClass)#1 (1) {
  ["parentName":"ParentClass":private]=>
  string(3) "joj"
}
joj