当前位置:网站首页>addslashes,stripslashes

addslashes,stripslashes

2022-06-21 15:59:00 51CTO

The official introduction :
(PHP 4, PHP 5)
addslashes — Use backslashes to reference strings
Return string , This string adds a backslash before some characters for the needs of database query statements, etc . These characters are single quotes (’)、 Double quotes (”)、 Backslash (\) And NUL(NULL character ).
PHP 5.4 Before PHP Instructions magic_quotes_gpc The default is on, Virtually all GET、POST and COOKIE Data are used by addslashes() 了 . Don't be right to have been magic_quotes_gpc Escaped strings use addslashes(), Because this will lead to double escape . In this case, you can use the function get_magic_quotes_gpc() To test .

      
      
// When magic_quotes_gpc=On When , function get_magic_quotes_gpc() It will return 1
// When magic_quotes_gpc=Off When , function get_magic_quotes_gpc() It will return 0
$str=$_POST["str"];// Read str The content of is assigned to $str Variable
if(get_magic_quotes_gpc())// If get_magic_quotes_gpc() It's open
{
$str=stripslashes($str);// Process strings
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

  that , The problem is coming. , Now use php5.6,get_magic_quotes_gpc() by false, But , Direct access to $_POST Value , Or just escaped , Why is that ???

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211536090182.html