我使用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以及教程的文档。 –