标签:for data strpos 请求 func account post count multi
> HTTP 常见 Content-Type
> application/x-www-form-urlencoded
> multipart/form-data
> application/json
> $_POST 默认只能接收到 Content-Type: application/x-www-form-urlencoded 的数据
> 如果Content-Type: application/json 需要用到php://input 处理输入流
> 请求内容 {"account": "123456"}
> $tmpData = strval(file_get_contents("php://input"));
> $DataArray = json_decode($tmpData, true);
> $account = $DataArray[‘account‘];
> $tmpData = strval(file_get_contents("php://input"));
> public function parseData($data) {
> $list = explode("\r\n", $data);
> foreach($list as $value) {
> if($value) {
> if(strstr($value, ‘--‘)) continue;
> if(strpos($value, ‘-‘)) {
> $key = str_replace(‘"‘, ‘‘, strchr($value, ‘"‘));
> continue;
> };
> if($value) {
> $array[$key] = $value;
> }
> }
> }
> return $array;
> }
> $DataArray = $this->parseData($tmpData);
> $DataArray[‘account‘];
标签:for data strpos 请求 func account post count multi
原文地址:http://blog.51cto.com/jinliang/2332741