【发布时间】:2011-03-30 20:02:16
【问题描述】:
html表单代码-
<td width="75">
<input name="txtQty[]" type="text" id="txtQty[]" size="5"
value="<?php echo $ct_qty; ?>" class="box" onKeyUp="checkNumber(this);">
当我提交表单时,我会调用以下脚本-
if (!get_magic_quotes_gpc()) {
if (isset($_POST)) {
foreach ($_POST as $key => $value) {
$_POST[$key] = trim(addslashes($value));
}
}
if (isset($_GET)) {
foreach ($_GET as $key => $value) {
$_GET[$key] = trim(addslashes($value));
}
}
}
错误-
警告:addslashes() 期望参数 1 是字符串,数组在 C:\xampp\htdocs\shizin\products\library\config.php 第 53 行给出
我认为这个脚本只是用来修剪输入,但我不知道这个 addlash 函数的作用以及为什么会出现这个错误。
【问题讨论】:
-
addslashes() 只返回一个在预定义字符前带有反斜杠的字符串。
-
关于您收到的错误..确保 $value 是一个字符串...
-
错误信息不是很明显吗?
$value不是字符串。
标签: php trim addslashes