判断是否为ajax请求

function isAjax()
{
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&  strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        return true;
    } else {
        return false;
    }
    
}

判断是否为post请求

function isPost()
{
    return ($_SERVER['REQUEST_METHOD'] == 'POST' && checkurlHash($GLOBALS['verify'])
        && (empty($_SERVER['HTTP_REFERER']) || preg_replace("~https?:\/\/([^\:\/]+).*~i", "\\1", $_SERVER['HTTP_REFERER']) == preg_replace("~([^\:]+).*~", "\\1", $_SERVER['HTTP_HOST']))) ? 1 : 0;
}

判断是否为get请求

function isGet()
{
    return $_SERVER['REQUEST_METHOD'] == 'GET' ? true : false;
}
Last modification:December 11th, 2019 at 02:11 pm
如果觉得我的文章对你有用,请随意赞赏