Last active
May 13, 2017 03:46
-
-
Save cjzeven/865c53a47cb3964f6fd63f16b737dfc2 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 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; | |
var_dump(empty($regular->name)); | |
$magic = new Magic; | |
var_dump(empty($magic->name)); | |
// Hasil: | |
// bool(false) | |
// bool(true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment