易腾动力社区

标题: php的magic_quotes_gpc转义 [打印本页]

作者: jaly    时间: 2015-12-11 11:01
标题: php的magic_quotes_gpc转义
1. 对于magic_quotes_gpc=on的情况,
我们可以不对输入和输出数据库的字符串数据作
addslashes()和stripslashes()的操作,数据也会正常显示。
如果此时你对输入的数据作了addslashes()处理,
那么在输出的时候就必须使用stripslashes()去掉多余的反斜杠。
2. 对于magic_quotes_gpc=off 的情况
必须使用addslashes()对输入数据进行处理,但并不需要使用stripslashes()格式化输出
因为addslashes()并未将反斜杠一起写入数据库,只是帮助mysql完成了sql语句的执行。
  1. //ini_set('magic_quotes_gpc', 'on');
  2. //if(!get_magic_quotes_gpc()){
  3. if(!ini_set('magic_quotes_gpc')){
  4.         $_POST['content'] = addslashes($_POST['content']);
  5. }
复制代码

作者: jaly    时间: 2018-9-8 11:03
Content-Type
application/x-www-form-urlencoded
application/json




欢迎光临 易腾动力社区 (http://bbs.yidz.cn/) Powered by Discuz! X3