我得到這個錯誤:致命錯誤:不能重新聲明類客戶
Fatal error: Cannot redeclare class Customer
然後,我添加以下代碼:
if (!class_exists('Customer')) {
include('include/customer.class.php');
}
爲什麼我仍然得到這個錯誤?
我有一個文件(file1.php),其中聲明瞭Customer()類。
在file1.php我做一個AJAX調用file2.php
在file2.php我再次聲明客戶()類。
在file2.php中,只有1個Customer()類的聲明。
你是否在其他地方包含'include/customer.class.php'? – Twelve47 2011-04-10 10:42:27
你有在別處聲明過的名爲'Customer'的類嗎?這是唯一的方法,這是有道理的。 – 2011-04-10 10:47:49
是的,這就是爲什麼我加入if(!class_exists('Customer')) – 2011-04-10 10:47:53