Here is the code of registry I'd like to use. But static
doesn't work as it should. In this example it always returns 2 (while 1 is expected). What can it be?
<?php
class CommonRegistry{
protected static $register;
public static function show()
{
return static::$register;
}
}
class NewRegister extends CommonRegistry{
public function __construct($num)
{
static::$register = $num;
}
}
class AnotherRegister extends CommonRegistry
{
public function __construct($num)
{
static::$register = $num;
}
}
$a = new NewRegister(1);
$b = new AnotherRegister(2);
var_dump(NewRegister::show());