色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php中使用$_REQUEST需要注意的一個問題

問題
說起$_REQUEST,大家都知道的是它是$_GET和$_POST的集合。但是如果你有心的話,查一下文檔,會看到:

$_REQUEST

An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE.

這里說$_REQUEST默認是$_GET, $_POST, $_COOKIE的集合,結果我使用我本地的php查看了一下發現只有$_GET, $_POST, 沒有$_COOKIE!! 難道文檔是錯的?

 

答案
其實changelog中有給出解釋:

版本5.3以上,php.ini中有request_order屬性來設置$_REQUEST。查了下php.ini, request_order設置成為了GP(Get and Post)。

 

request_order的官網描述:

request_order string

This directive describes the order in which php registers GET, POST and Cookie variables into the _REQUEST array. Registration is done from left to right, newer values override older values.

If this directive is not set, variables_order is used for $_REQUEST contents.

Note that the default distribution php.ini files does not contain the 'C' for cookies, due to security concerns.

 

原來是G,P,C分別代表Get,Post,Cookie,5.3以上的版本request_order默認是設置成GP的,并不包含C,即$_REQUEST默認只包含$_GET和$_POST !! (所以官網文檔有一定的誤導)。

 

也同時說一下G,P,C的先后順序就是設置的array的覆蓋順序。

提醒下如果你是使用fpm-php實驗的話,改了php.ini后你需要重啟php-fpm

php技術php中使用$_REQUEST需要注意的一個問題,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 隆回县| 山阳县| 远安县| 高台县| 瑞金市| 德保县| 鹤岗市| 通榆县| 新乡市| 柯坪县| 唐海县| 蓝山县| 河北省| 固镇县| 渭源县| 金湖县| 北碚区| 永安市| 昌宁县| 北安市| 福建省| 杨浦区| 北票市| 临颍县| 开阳县| 五河县| 繁峙县| 石河子市| 视频| 玉溪市| 宿州市| 通河县| 新宾| 甘南县| 韩城市| 葫芦岛市| 民县| 邹平县| 进贤县| 成武县| 上虞市|