Я упростила свой класс для лучшего понимания.Почему method2 выдает ошибку, что self :: $ dbconn имеет значение null?Когда удалить __desctruc () он работает нормально?
Я называю это так:
$test = new TestCtrl();
$test->getList(123);
...
class TestCtrl {
private static $dbconn;
function __construct(){
self::$dbconn = 'assume this is my db connection...';
}
function __destruct() {
self::$dbconn = null;
}
private function method1($contact){
$metas = self::method2();
return $metas;
}
private static function method2(){
$res = self::$dbconn;
return $res;
}
public function getList($contact){
return self::method1($contact);
}
}