我使用Dreamweaver爲我生成了一些PHP,並將此代碼放在頁面的頂部。我只是在想,如果有人能告訴我我是否真的需要它,它會做什麼? (我知道的過時的mysql)...這個PHP代碼是否必要?
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
有沒有辦法讓我們知道,如果你需要與否。它似乎爲MySQL查詢準備了值。 – JJJ
這將檢查是否存在名爲GetSQLValueString的函數,如果不存在,則創建它。它似乎是Dreamweaver需要的自定義函數。但是,要發現,您需要在包含此操作的任何文件中執行查找操作,並查看GetSQLValueString是否實際上正在被調用。它看起來像這個函數使用了很多古代/廢棄的代碼,你可能可以用更好的東西代替它。 – raphael75
對於OP:如果你不知道它做了什麼,爲什麼發佈一個問題呢?這取決於你閱讀關於PHP/MySQL以及教程的文檔。 –