Skip to content

Instantly share code, notes, and snippets.

@beeblebrox3
Last active September 30, 2015 14:00
Show Gist options
  • Save beeblebrox3/0b5c2efd176ce3c4370e to your computer and use it in GitHub Desktop.
Save beeblebrox3/0b5c2efd176ce3c4370e to your computer and use it in GitHub Desktop.
<?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