工学1号馆

home

后端接收前端传递的json字符串问题

Wu Yudong    October 11, 2019     ThinkPHP   1,139   

今天在项目中想实现一个功能如标题所示,最开始的方法是使用$this->request->param()来接收

但是失败,接着使用input等都失败了

后来查找资料后使用下面的代码搞定

$param = file_get_contents('php://input');
if(empty($param) === false){
    $param = json_decode($param, true);
}

关于file_get_contents(‘php://input’)

可以自行baidu

如果文章对您有帮助,欢迎点击下方按钮打赏作者

Comments

No comments yet.
To verify that you are human, please fill in "七"(required)