哪些超全局变量受magic_quotes_gpc = 1影响? [英] Which superglobals are affected by magic_quotes_gpc = 1?
问题描述
通过查看此伪指令的名称,可能会认为magic_quotes
仅适用于$_GET
,$_POST
和$_COOKIE
超全局变量,但是有
By looking at the name of this directive one may think that magic_quotes
are only applied to $_GET
, $_POST
and $_COOKIE
superglobals but there is one perturbing comment on the PHP Manual:
请注意, 不仅设置了
magic_quotes_gpc
$_POST
,$_GET
,$_REQUEST
,$_COOKIE
数组值被斜线了.实际上$GLOBALS
数组中的每个字符串值 被削减,即.$GLOBALS['_SERVER']['PATH_INFO']
(或$_SERVER['PATH_INFO']
).
Please note, that when
magic_quotes_gpc
is set not only$_POST
,$_GET
,$_REQUEST
,$_COOKIE
arrays values are slashed. Actually every string value in$GLOBALS
array is slashed, ie.$GLOBALS['_SERVER']['PATH_INFO']
(or$_SERVER['PATH_INFO']
).
任何人都可以确认这是真的吗?超全局变量$GLOBALS
,$_SERVER
,$_FILES
,$_SESSION
和$_ENV
也受到影响吗?
Can anyone confirm that this is true? Are the superglobals $GLOBALS
, $_SERVER
, $_FILES
, $_SESSION
and $_ENV
affected as well?
另一个问题,如果我在$_GET
,$_POST
和$_COOKIE
数组上迭代stripslashes()
,是否还需要遍历$_REQUEST
数组?还是会自动反映出更改?
One more question, if I iterate stripslashes()
over the $_GET
, $_POST
and $_COOKIE
arrays do I also need to iterate through the $_REQUEST
array? Or are the changes automatically reflected?
推荐答案
我已经对LightTPD 1.4.20
和PHP 5.3.0
进行了一些测试,其中magic_quotes_gpc = On
和$_SERVER
并未更改(至少[SERVER_NAME] => local'host
没有'). $_SESSION
也不受magic_quotes的影响.
I've run some tests on LightTPD 1.4.20
and PHP 5.3.0
with magic_quotes_gpc = On
and $_SERVER
wasn't altered (at least [SERVER_NAME] => local'host
didn't). $_SESSION
also isn't affected by magic_quotes.
$_GET
,$_POST
,$_COOKIE
和$_REQUEST
(及其对应的$GLOBALS
)受到了影响.
$_GET
, $_POST
, $_COOKIE
and $_REQUEST
were affected (and their $GLOBALS
counterparts).
此外,GPC
超全局变量中的更改不会自动反映在$_REQUEST
中.
Also, the changes in the GPC
superglobals aren't automatically reflected in $_REQUEST
.
对于$_FILES
和$_ENV
超全局变量,我无法对其进行ATM测试.
As for the $_FILES
and $_ENV
superglobals I'm not able to test them ATM.
我终于运行了该测试,令我惊讶的是$_FILES
和php://input
都受到了的影响.
I've finally ran this test and, to my surprise, both $_FILES
and php://input
are affected.
这篇关于哪些超全局变量受magic_quotes_gpc = 1影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!