<?php
namespace ns;
class People
{
public function __construct()
{
echo "Construct People \n";
}
public function __call($method, $args)
{
echo "Not exist $method \n";
}
public static function __callStatic($method, $args)
{
echo "Not exist static $method \n";
}
public function go()
{
echo "Call class method go \n";
}
public static function run()
{
echo "Call static method run \n";
}
}
$p = new People;
$p->exit('exit');
People::done('done');
先贴上一段代码:
People
实例对象调用exit
方法, 但People
类中并没有exit
方法, 此时就会调用__call
方法, 并将方法名和参数传递给__call
方法__callStatic
则是用于调用_静态方法_时的处理