PHP 接口方式接收POST

 

一般我们都会用body 发送post 数据,那么PHP如何接收呢?

<?php

$jsonStr = file_get_contents('php://input');

if (!$jsonStr) {

return $this->jsonCode('参数有误!', 1);

} else {

$json = json_decode($jsonStr, true);

$jsonData = $json ? $json['studyData'] : '';

if (!$jsonData) {

return $this->jsonCode('参数不能为空!', 1);

}

}

 

 

文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。

__________________________________________________________________________________

若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)

posted @   刘俊涛的博客  阅读(1022)  评论(0编辑  收藏  举报
Servbay
点击右上角即可分享
微信分享提示