色尼玛亚洲综合影院,亚洲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需要注意的一個問題,轉載需保留來源!

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

主站蜘蛛池模板: 象山县| 吉安市| 茶陵县| 三门峡市| 海城市| 循化| 东港市| 集安市| 北票市| 博野县| 贺兰县| 德保县| 柳河县| 平潭县| 鄂托克前旗| 贵州省| 惠来县| 察哈| 囊谦县| 军事| 收藏| 天门市| 紫金县| 会理县| 崇州市| 新安县| 丰镇市| 东山县| 绥滨县| 丰城市| 南投县| 彭州市| 隆化县| 青神县| 杨浦区| 衡南县| 石渠县| 澎湖县| 吉隆县| 屏东县| 会泽县|