Last active
September 30, 2015 14:00
-
-
Save beeblebrox3/0b5c2efd176ce3c4370e to your computer and use it in GitHub Desktop.
This file contains 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 Xpto | |
{ | |
private $data = array ( | |
'a' => 'b', | |
); | |
public $b = '1'; | |
public function __get($key) | |
{ | |
var_dump($key); | |
$a = $this->data; | |
return $a[$key]; | |
} | |
} | |
$obj = new Xpto; | |
var_dump($obj->a); // imprime "a" de dentro da __get e depois imprime "b", que é o valor retornado | |
var_dump(empty($obj->a)); // não passa pela __get |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment