我正在Zend項目上工作,自從我觸及Zend已經超過12個月,我得到了一個函數的錯誤,我不知道爲什麼,我認爲它可能是直到最初在PHP(5.2)的早期版本中構建的網站,現在我正在運行5.3。PHP問題與get_class
功能看起來像這樣,
public function addDebug($mixedObject, $title = "")
{
$debugObject = new stdClass();
$debugObject->title = $title;
$debugObject->type = gettype($mixedObject);
$debugObject->className = (!get_class($mixedObject)) ? "" : gettype($mixedObject);<-- Line error is complaining about -->
$debugObject->mixedObject = $mixedObject;
array_push($this->debugArr, $debugObject);
}
該錯誤消息如下,
get_class() expects parameter 1 to be object, array given in /server/app/lib/View.php on line 449
在這個問題上任何意見將是一件好事。
你真的看過錯誤信息嗎?因爲它已經說明了導致錯誤的原因,即您將數組傳遞給addDebug函數而不是對象。所以無論你的邏輯(即get_class調用)是錯誤的,或者你傳遞錯誤的參數到你的函數。 – wimvds 2010-05-20 09:56:44