Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 PHP 中为 $_REQUEST 变量赋值?例如:
if ($_REQUEST['name'] == "") { $_REQUEST['name'] = "John"; }
是的。$_REQUEST是一个和其他变量一样的变量,但可以预先填充并且是超全局的。
$_REQUEST
似乎该变量是只读的,如果要保存全局变量,可以尝试在全局范围内创建一个新变量,如下所示:
$GLOBALS['some_var'] = 'new var';
然后您可以在代码中的任何位置获取值,如下所示:
$your_var = $GLOBAS['some_var'];