php中使用$_REQUEST需要注意的一個(gè)問題_PHP教程
推薦:基于MySQL分區(qū)性能的詳細(xì)介紹本篇文章介紹了,對MySQL分區(qū)性能的詳細(xì)說明,需要的朋友參考下
問題
說起$_REQUEST,大家都知道的是它是$_GET和$_POST的集合。但是如果你有心的話,查一下文檔,會(huì)看到:
$_REQUEST
An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE.
這里說$_REQUEST默認(rèn)是$_GET, $_POST, $_COOKIE的集合,結(jié)果我使用我本地的php查看了一下發(fā)現(xiàn)只有$_GET, $_POST, 沒有$_COOKIE!! 難道文檔是錯(cuò)的?
答案
其實(shí)changelog中有給出解釋:
版本5.3以上,php.ini中有request_order屬性來設(shè)置$_REQUEST。查了下php.ini, request_order設(shè)置成為了GP(Get and Post)。
request_order的官網(wǎng)描述:
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默認(rèn)是設(shè)置成GP的,并不包含C,即$_REQUEST默認(rèn)只包含$_GET和$_POST !! (所以官網(wǎng)文檔有一定的誤導(dǎo))。
也同時(shí)說一下G,P,C的先后順序就是設(shè)置的array的覆蓋順序。
提醒下如果你是使用fpm-php實(shí)驗(yàn)的話,改了php.ini后你需要重啟php-fpm
分享:記錄mysql性能查詢過程的使用方法本篇文章介紹了,記錄mysql性能查詢過程的使用方法。需要的朋友參考下
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-php中使用$_REQUEST需要注意的一個(gè)問題。