存档
今天一同事问我,他用了Content-Type=text/xml型,提交了一个xml文档内容给了php server,要怎么获得这个POST数据。
这把我愣住了,以前确实没写过这样的POST,赶紧查手册,发现有$HTTP_RAW_POST_DATA 这一项。对此的解释是:The RAW / uninterpreted HTTP POST information can be accessed with: $GLOBALS['HTTP_RAW_POST_DATA'] This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).
意思是,由于PHP默认只识别application/x-www.form-urlencoded标准的数据类型,因此,对型如text/xml的内容无法解析为$_POST数组,故保留原型,交给$HTTP_RAW_POST_DAT来接收。
五 11th, 2009 | Filed under PHP
标签: HTTP_RAW_POST_DATA, php
最新评论