189 8069 5689

PHP接收get、post、json格式数据

public static function getParams()
{
    $params = $_GET;
    $params = array_merge($params, $_POST);
    $contentType = empty($_SERVER['CONTENT_TYPE']) ? '' : $_SERVER['CONTENT_TYPE'];
    if (empty($_POST) && false !== strpos($contentType, 'application/json')) {
        $content = file_get_contents('php://input');
        $params = array_merge($params, (array)json_decode($content, true));
    }
    return $params;
}

网页名称:PHP接收get、post、json格式数据
转载来于:http://cdxtjz.cn/article/igechi.html

其他资讯