Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. class GrandClass {
  2. public $data;
  3. public function __construct() {
  4. $this->someMethodInTheParentClass();
  5. }
  6. public function someMethodInTheParentClass() {
  7. $this->$data = 123456;
  8. }
  9. }
  10.  
  11. class MyParent extends GrandClass{
  12. public function __construct() {
  13. parent::__construct();
  14. }
  15. }
  16.  
  17. class Child extends MyParent {
  18. // public $data;
  19. public function __construct() {
  20. parent::__construct();
  21. }
  22. public function getData() {
  23. return $this->data;
  24. }
  25. }
  26.  
  27. $a = new Child();
  28. var_dump($a->getData());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement