数据放入数据库时需使用addslashes()函数,使用之后,字符串会带着斜杠存入数据库中
取出数据时使用stripslashes()函数将斜杠去掉
这两个的使用是相互结合的,缺一不可!
string addslashes( string str)
返回字符串,该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(\')、双引号(\")、反斜线(\\)与 NUL(NULL 字符)
stripslashes
作用相反
<?php
$str = \"Is your name O\\\'reilly?\";
// Outputs: Is your name O\'reilly?
?>
取出数据时使用stripslashes()函数将斜杠去掉
这两个的使用是相互结合的,缺一不可!
string addslashes( string str)
返回字符串,该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(\')、双引号(\")、反斜线(\\)与 NUL(NULL 字符)
stripslashes
作用相反
<?php
$str = \"Is your name O\\\'reilly?\";
// Outputs: Is your name O\'reilly?
?>