Skip to main content
 首页 » 编程设计

php之读取斜线输入崩溃

2025年12月25日46leader

将输入保存到数据库时出现问题。

我将字符串另存为:

mysql_real_escape_string($my_string) 

然后,我阅读并使用以下命令将字符串放置到输入中:
stripslashes($my_string) 

关键是,如果我在字符串中设置双斜杠,则输入将崩溃,如下所示:
<input maxlength = "150" type="text" name = "my_string12" value = "hello "this is" a test"  class="input-medium"/> 

谢谢。

请您参考如下方法:

如果将值作为PHP变量,则必须对其进行修剪..

使用修剪功能:

$str = 'hello "this is" a test'; 
echo trim($str, '"'); // hello this is a test 

保罗在 here回答