欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php addslashes 递归实现反斜线引用字符串的方法

程序员文章站 2022-03-17 13:15:08
...
本文介绍下,php利用递归实现使用反斜线引用字符串的方法,通过一个例子,帮助大家的理解。

php addslashes 递归反斜线引用字符串,代码如下:

'";
$_GET['STR1'] = 'fanglor " is \ a  boy  >';

echo '当前get_magic_quotes_gpc为  '.get_magic_quotes_gpc();
echo "
"; //判断当前是否开启get_magic_quotes_gpc //by bbs.it-home.org if (!get_magic_quotes_gpc()){ $_POST = addslashes_deep($_POST); $_GET = addslashes_deep($_GET); $_COOKIE = addslashes_deep($_COOKIE); } //打印结果 var_dump ($_POST); echo "
"; var_dump ($_GET); ?>

打印结果:

当前get_magic_quotes_gpc为 0 array(1) { ["STR"]=> string(30) "\'fanglor \' is \\ a boy >\'" } array(1) { ["STR1"]=> string(26) "fanglor \" is \\ a boy >" }