我有以下類到我的主類中的另一個類。PHP OOP - 從類內的另一個類調用靜態方法
class Products
{
public function __get($key){
return trim(functions::mssql_escape_string_rev($this->fields[ $key ]));
}
}
這回人類錯誤:Call to undefined method functions::mssql_escape_string_rev()
是不是有什麼毛病我的語法或可這不能做?
下面是用於自動載入類的代碼,這適用於其他任何事情,所以我知道代碼沒有錯誤。它似乎並沒有在課堂上發起。
// autoloader function called when we try to instantiate a class but haven't included the file
function __autoload($resource_name){
$resource_name = trim($resource_name);
try {
$filepath = CLASS_PATH."/class.".$resource_name.".inc.php";
if(@!include($filepath)){
throw new Exception('');
}
} catch(Exception $e) {
exit("Could not find the required file: ".$resource_name);
}
}
** * ****編輯* **** 請忽略這一點,我犯了一個愚蠢的錯誤,其中包括功能:: mssql_escape_string_rev兩次。對不起,時間浪費..
「功能」是你的另一類嗎? – hungneox 2011-12-20 12:32:53
函數是你定義的類嗎? – Sudantha 2011-12-20 12:37:17
是的,它是一個充滿靜態功能的類。 – LeeTee 2011-12-20 12:37:21