Php str_ireplace()未准确移除';打捆针';

Php str_ireplace()未准确移除';打捆针';,php,string,security,Php,String,Security,我使用str_ireplace()删除数组中字符串的实例,并返回计数的发生次数,但它实际上没有执行替换 //replace occurances of insert, update, delete, select $dmlArray = array('select', 'update', 'delete', 'insert'); str_ireplace($dmlArray,'-- replaced DML -- ',$clean['comment'],$Incount); 其中$clean

我使用str_ireplace()删除数组中字符串的实例,并返回计数的发生次数,但它实际上没有执行替换

//replace occurances of insert, update, delete, select
$dmlArray = array('select', 'update', 'delete', 'insert');

str_ireplace($dmlArray,'-- replaced DML -- ',$clean['comment'],$Incount);
其中$clean['comment']将是$\u POST数组

例如,
$clean['comment']=“选择、插入、更新、删除”

最后一个字符串应该是“-replacementeddml-,--replacementeddml-,--replacementeddml-,--replacementeddml-”


但事实并非如此

我已经运行了你的代码,它可以正常工作

echo str_ireplace(
    array('select', 'update', 'delete', 'insert'),
    '-- replaced DML -- ',
    'SELECT, insert, UPDATE, DEleTe',
    $Incount);
以上将输出

-- replaced DML -- , -- replaced DML -- , -- replaced DML -- , -- replaced DML --

请记住,输入字符串不是通过引用传入的,因此您必须使用返回值来获取替换了值的字符串。

我已经运行了您的代码,它可以正常工作

echo str_ireplace(
    array('select', 'update', 'delete', 'insert'),
    '-- replaced DML -- ',
    'SELECT, insert, UPDATE, DEleTe',
    $Incount);
以上将输出

-- replaced DML -- , -- replaced DML -- , -- replaced DML -- , -- replaced DML --

请记住,输入字符串不是通过引用传入的,因此必须使用返回值来获取替换了值的字符串。

函数
stru ireplace
不会更改其参数。它返回结果。下面是代码的修复程序:

$clean['comment'] = str_ireplace($dmlArray, '-- replaced -- ', $clean['comment'], $Incount);

函数
stru ireplace
不会更改其参数。它返回结果。下面是代码的修复程序:

$clean['comment'] = str_ireplace($dmlArray, '-- replaced -- ', $clean['comment'], $Incount);

你得到的是什么?我得到的是原始字符串。它好像在工作,但不是。“看起来你在写一个半心半意的尝试来清理SQL字符串文本中插入的内容。你需要帮助吗?”(*)获得如何使用SQL转义的帮助(*)继续用你的头敲击它你得到了什么?我得到了原始字符串。它好像在工作,但不是。“看起来你在写一个半心半意的尝试来清理SQL字符串文本中插入的内容。你想要帮助吗?”(*)获取有关如何使用SQL转义的帮助(*)继续用你的头敲击它