Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在 php 中用 \\b 替换 \b 才能插入到 mysql 表中。
因此 \bhello\b 变成 \\bhello\\b 然后插入到 mysql 中,在那里它被转换回 \bhello\b。
但我似乎无法弄清楚如何。尝试了 preg_replace 和 str_replace ,我总是以错误或我开始的错误告终。
听起来您需要为数据库使用正确的转义机制。
郑重声明,这绝对不是addslashes()。
addslashes()
如果使用mysql_*(),则使用mysql_real_escape_string()。
mysql_*()
mysql_real_escape_string()
如果使用PDO,请将绑定参数与准备好的语句一起使用。