美文网首页
index.php接收post的数据

index.php接收post的数据

作者: APHOME_明 | 来源:发表于2018-05-31 11:01 被阅读0次

一、主要的接收方式有
1.检查头信息content-type是不是为“content-type:application/x-www-form-urlencoded" 这种传输是以表单的方式提交数据php使用$_POST方式接受。
2.如果头信息content-type是不是为“content-type:application/json"这种传输是以json方式提交数据,php需要使用file_get_contents("php://input")获取输入流的方式接受

$postdata = $_POST;
    if(empty($postdata)){
        $postdata = $_REQUEST;
    }
    if(empty($postdata)){
        $postdata = $_GET;
    }
    if(empty($postdata)){
        $postdata = file_get_contents("php://input");
    }

二、修改php.ini配置文件enable_post_data_reading=on

相关文章

网友评论

      本文标题:index.php接收post的数据

      本文链接:https://www.haomeiwen.com/subject/lhfqsftx.html