1
我可以使用神奇的方法来捕捉Access to undeclared static property
不可访问的静态属性吗?魔术方法 - 我可以使用它们来捕捉无法访问的静态属性吗?
例如,
class greeting
{
static public function init()
{
static::$message = 'Hello World!';
}
/*
* Set the inaccessible property magically.
*/
public function __set($name, $value)
{
var_dump($name); // set the property here?
}
/*
* Get the inaccessible $class magically.
*/
public function __get($name)
{
var_dump($name); // set the property here?
}
}
greeting::init();
var_dump(greeting::$message);
我得到的,
Fatal error: Access to undeclared static property: greeting::$messsage in C:...
感谢您的回答!顺便说一句,[主题问题]你用什么程序来测试以获得这些结果'2,319s/1,416s/3,708s'? – laukok 2014-11-23 14:10:42
没有使用任何,只是写了一个小脚本和测量时间戳执行前后用php方法microtime(true) – sasha 2014-11-24 08:55:37
我应该写测试呢!谢谢! – laukok 2014-11-24 09:41:37