PHP当字符串是mysqli_real_escape_string的两倍时会发生什么 [英] PHP what happens when a string is double times mysqli_real_escape_string

查看:218
本文介绍了PHP当字符串是mysqli_real_escape_string的两倍时会发生什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当回显 mysqli_real_escape_string($ db,mysqli_real_escape_string($ db,''));



其中一个将是输出:
1. \
2. \\\



是否一个安全的方法来检查一个字符串是否已被转义?



不幸的是,目前我无法测试,因为我无法访问MySQL 24小时。

解决方案

输出是 \\\(你的第二个例子) p>

我不认为你可以确定一个字符串是否已经被转义,你应该按照你只能调用 mysqli_real_escape_string()一次。


I'm using mysqli.

When I echo mysqli_real_escape_string($db,mysqli_real_escape_string($db,'"'));

which one of those will be the output: 1. \" 2. \\\" ?

Is there a safe way to check whether a string has been already escaped?

Unfortunately, I cannot test at present as I cannot access MySQL for 24 hours.

解决方案

The output is \\\" (your second example).

I don't think you can reliably say whether a string has already been escaped or not, you should organize your code in a way that you only can call mysqli_real_escape_string() once.

这篇关于PHP当字符串是mysqli_real_escape_string的两倍时会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆