php的$HTTP_RAW_POST_DATA

五 11th, 2009

今天一同事问我,他用了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来接收。

  1. Veidy.lei
    五 12th, 200911:06

    学习了

;) :| :x :twisted: :roll: :oops: :o :mrgreen: :lol: :idea: :evil: :cry: :arrow: :P :D :?: :? :) :( :!: 8O 8)

Spam Protection by WP-SpamFree