Exemplo n.º 1
0
$result = empty($db->host);
class Politician
{
    // called when calling a non-existing method
    public function __call($method, $arguments)
    {
        echo __CLASS__ . " has no method called {$method}" . PHP_EOL;
    }
    // called when calling a non-existing static method
    public function __callStatic($method, $arguments)
    {
        echo __CLASS__ . " has no static method called {$method}" . PHP_EOL;
    }
}
$foo = new Politician();
$foo->honesty();
Politician::loyalty();
class CallableObject
{
    // called when calling an object as a function
    public function __invoke($number)
    {
        return $number ** 2;
    }
}
$obj = new CallableObject();
echo $obj(10) . PHP_EOL;
class DebugObject
{
    private $private = 10;
    protected $protected = 20;