Last active
          August 3, 2017 00:09 
        
      - 
      
- 
        Save caoglish/8bd570cd53a43256a84ec8fa812ec61f to your computer and use it in GitHub Desktop. 
    __get and property
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| class sample | |
| { | |
| public function __get($p) | |
| { | |
| $list=["name"=>"magic"]; | |
| return $list[$p]; | |
| } | |
| } | |
| class sampleA extends sample | |
| { | |
| } | |
| class sampleB extends sample | |
| { | |
| public $name="property"; | |
| } | |
| $a =new sampleA; | |
| var_dump($a->name) ;//magic | |
| $b =new sampleB; | |
| var_dump($b->name) ;//property | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment