为什么此代码输出“三分之三”?
<?php
abstract class xyz {
static $var;
public static function setVar($value) {
static::$var = $value;
}
}
class one extends xyz {}
class two extends xyz {}
class three extends xyz {}
call_user_func('one::setVar', 'first');
call_user_func('two::setVar', 'second');
call_user_func('three::setVar', 'third');
echo "<pre>";
echo one::$var."\n";
echo two::$var."\n";
echo three::$var."\n";
echo "</pre>";
我本来会以为第一,第二是第三
我在这里想念什么?
这是我的决心
public static function setVar($value) {
$class = get_called_class();
$class::$var =& $value;
}