比如有這樣的一個HTTP的GET請求:
http://ask.segmentfault.com/api?state.code=16
PHP會自動把$_REQUEST["state.code"]轉(zhuǎn)義為$_REQUEST["state_code"]
官方有這樣的一個說明:
Dots and spaces in variable names are converted to underscores. For example <input name="a.b" /> becomes $_REQUEST["a_b"].
因為后端存儲用的是MongoDB,所以希望能查詢json內(nèi)嵌的的數(shù)據(jù),所以希望支持“點”這種方式的查詢。針對這種問題應(yīng)該如何解決呢?
順便說下,PHP的Web Framework用的是Laravel。
光陰似箭催人老,日月如移越少年。
http://ask.segmentfault.com/api?rq[state.code]=16
/** PHP **/
$_GET['rq']['state.code'];
在數(shù)組內(nèi)是不會被轉(zhuǎn)的,雖然麻煩了點,不過不失為一種解法…