Skip to content

Instantly share code, notes, and snippets.

@cjzeven
Created May 13, 2017 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjzeven/fd27dcb4b43c74af5920032202dbdfea to your computer and use it in GitHub Desktop.
Save cjzeven/fd27dcb4b43c74af5920032202dbdfea to your computer and use it in GitHub Desktop.
<?php
class Regular
{
public $name = 'Something';
}
class Magic
{
private $values = ['name' => 'Something'];
public function __get($key)
{
if (isset($this->values[$key])) {
return $this->values[$key];
}
}
}
$regular = new Regular;
echo $regular->name, "\n";
$magic = new Magic;
echo $magic->name, "\n";
// Hasil:
// Something
// Something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment