新聞中心
> HTTP 常見 Content-Type
創(chuàng)新互聯(lián)專注于沙縣網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供沙縣營銷型網(wǎng)站建設(shè),沙縣網(wǎng)站制作、沙縣網(wǎng)頁設(shè)計(jì)、沙縣網(wǎng)站官網(wǎng)定制、小程序制作服務(wù),打造沙縣網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供沙縣網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
application/x-www-form-urlencoded
multipart/form-data
application/json> $_POST 默認(rèn)只能接收到 Content-Type: application/x-www-form-urlencoded 的數(shù)據(jù)
> 如果Content-Type: application/json 需要用到php://input 處理輸入流
請(qǐng)求內(nèi)容 {"account": "123456"}
$tmpData = strval(file_get_contents("php://input"));
$DataArray = json_decode($tmpData, true);
$account = $DataArray['account'];- > Content-Type: multipart/form-data
$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'];
網(wǎng)站欄目:原生PHP接收$_POST的幾種方式
路徑分享:http://fisionsoft.com.cn/article/jcciej.html