Why is this code outputting "third third third"?
<?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>";
I would have thought first, second third
What am I missing here?
Update
This was my resolution
public static function setVar($value) {
$class = get_called_class();
$class::$var =& $value;
}