fork download
  1. <?php
  2.  
  3. class A {
  4. protected $token = 'tttttttt';
  5. function aa() {
  6. $res = $this->token;
  7. return $res;
  8. }
  9. }
  10.  
  11. class B extends A
  12. {
  13. public function __get($name) {
  14. switch($name) {
  15. case 'token': return $this->getToken();
  16. }
  17.  
  18. return null;
  19. }
  20.  
  21. function aa() {
  22. return $this->getToken();
  23. }
  24.  
  25. private function getToken() {
  26. return '666666666';
  27. }
  28. }
  29.  
  30. $b = new B();
  31. $bb = $b->aa();
  32. echo "$bb\n";
  33. echo "$b->token\n";
Success #stdin #stdout 0.01s 24456KB
stdin
Standard input is empty
stdout
666666666
666666666