Имеется это изменилось между PHP8.0 и 8.1?
Код для воспроизведения
Код: Выделить всё
class top{
public function cacheValue(){
static $cache;
if (!isset($cache)) {
$cache=get_class($this)."\n";
}
return $cache;
}
}
class child1 extends top{
}
class child2 extends top{
}
$a = new child1;
$b = new child2;
echo $a->cacheValue();
echo $b->cacheValue();
ребенок1
ребенок2
Фактический результат:ребенок1
ребенок1
Подробнее здесь: https://stackoverflow.com/questions/792 ... ss-objects
Мобильная версия