【发布时间】:2020-08-15 02:48:42
【问题描述】:
public function InitButton($Name, $Group, $T=0, $L=0, $W=1, $H=1, $BStyle=null, $Text='', $Expire = 0, $Repeat=true)
{
$OldButton = ButtonManager::getButtonForKey($this->UCID, $Name);
//Line 4 below:
if(get_class($OldButton) == 'Button') {
$Button = $OldButton;
} else {
$Button = new Button($this->UCID, $Name, $Group);
}
$Button->T($T)->L($L)->W($W)->H($H);
$Button->BStyle($BStyle);
if(is_array($Text)) {
$Button->Text($Text[0]);
$this->bTexts[$Name] = $Text;
} else {
$Button->Text($Text);
$this->bTexts[$Name][0] = $Text;
}
$Button->Send();
$this->bState[$Name]['ID'] = 0;
$this->bState[$Name]['timestamp'] = time() - 1;
$this->bState[$Name]['override'] = false;
if($Expire > 0) {
$this->bState[$Name]['expire'] = time() + $Expire;
} else {
$this->bState[$Name]['expire'] = -1;
}
$this->bState[$Name]['repeatText'] = $Repeat;
}
PHP 警告:get_class() 期望参数 1 为对象,在第 4 行的 C:\Users\HP\Desktop\test\test.php 中给出 null
我该如何解决这个问题?
【问题讨论】:
-
$OldButton 为 null 而不是对象。使用 var_dump() 进行测试。
标签: php