fork download
  1. <?php
  2. abstract class Person{
  3. private $age;
  4. public abstract function show_age();
  5. }
  6. class Student extends Person{
  7. function __construct($age)
  8. {
  9. $this->age = $age;
  10. //Person::$age = $age;
  11. }
  12. public function show_age()
  13. {
  14. echo "$this->age \n";
  15. }
  16. }
  17. $s=new Student(31);
  18. $s->show_age();
  19. print_r($s);
Success #stdin #stdout 0.03s 25820KB
stdin
Standard input is empty
stdout
31 
Student Object
(
    [age:Person:private] => 
    [age] => 31
)