Home  >  Article  >  php教程  >  php中的 $

php中的 $

WBOY
WBOYOriginal
2016-06-06 19:49:301092browse

明显,这三个都是为了获取通过http发送到服务器的数据。 php默认能识别的数据类型(MIME) 是 application/x-www.form-urlencoded ,常见情况就是表单的提交,一般提交过来的数据都是形如 k1=v1k2=v2k3=v3...... 这种 form-urlencoded 。这种数据php会解析到 $

明显,这三个都是为了获取通过http发送到服务器的数据。
php默认能识别的数据类型(MIME) 是application/x-www.form-urlencoded ,常见情况就是表单的提交,一般提交过来的数据都是形如 k1=v1&k2=v2&k3=v3...... 这种 form-urlencoded 。这种数据php会解析到 $_POST 中,也就是我们通常在提交表单操作中使用到的那样。但是当用户post过来的数据是 xml格式的字符串,php是不能这种数据类型解析到$_POST 数组中的,但这会在 $GLOBALS 里面存储post过来的原始数据的,就是 $GLOBALS['HTTP_ROW_POST_DATA'] ,其实 $_POST 中的数据也就是从这个数组里面分析出来填充到 $_POST 的(若无法识别为 urlencoded,则为空)。
也就是说当我们想要接收 xml 格式的post数据就只能用$GLOBALS['HTTP_ROW_POST_DATA'] 了。当然还有一个 php://input , 这个是IO stream的协议,php会解析这个协议为post过来的元素数据 也就是说 file_get_contents('php://input') = $GLOBALS['HTTP_ROW_POST_DATA']

但是当我们post二进制文件到服务器的话,这些是都不能识别的, 比如 enctype='multipart/form-data' 这种 MIME ,php给我们提供了 $_FILES 数组来获取这种数据的信息。

先在CSDN支持MarkDown,很好啊!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php setNext article:php构造函数和析构函数