判断是否为ajax请求
代码语言:javascript复制function isAjax()
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
return true;
} else {
return false;
}
}
判断是否为post请求
代码语言:javascript复制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请求
代码语言:javascript复制function isGet()
{
return $_SERVER['REQUEST_METHOD'] == 'GET' ? true : false;
}
版权属于:尹深
本文链接:https://cloud.tencent.com/developer/article/1795045
转载时须注明出处及本声明
(本站部分资源来自互联网收集整理!如有侵权请联系站长删除!!!)