Consider the following snippets of code:
Exhibit A:
$_REQUEST = json_decode(stripslashes(json_encode($_REQUEST, JSON_HEX_APOS)), true);
Exhibit B:
${'_REQUEST'} = json_decode(stripslashes(json_encode(${'_REQUEST'}, JSON_HEX_APOS)), true);
Exhibit C:
${'_' . 'REQUEST'} = json_decode(stripslashes(json_encode(${'_' . 'REQUEST'}, JSON_HEX_APOS)), true);
Both exhibit A and B work perfectly fine, exhibit C however displays a very strange error message:
Notice: Undefined variable: _REQUEST
What makes it even more weird is that this only happens with the $_REQUEST superglobal, if I try it with $_GET, $_POST or $_COOKIE all experiments work fine without raising error notices.
I’m guessing this is a PHP bug? I’m running on PHP 5.3.0.
(I tested with PHP 5.3.1)
One funny thing is that this portion of code :
Gets the notice
Undefined variable: _REQUESTBut this one :
Doesn’t give any notice, and shows two empty arrays.
For a while, I though this could be related to
auto_globals_jit, but$_REQUESTdoesn’t seem to the concerned by that directive… But there is one interested thing said, here :Maybe, after all, even if it’s not said in the manual,
auto_globals_jithas an impact on$_REQUEST…And, to be sure, I turned Off
auto_globals_jitin myphp.inifile :And tried this code again :
And I now get an empty array, and not a notice anymore.
So it seems
auto_globals_jitdoes indeed have an impact on$_REQUEST— even if it’s not mentionned in the manual.