下列函数返回结果为true或false;
## POST
函数用来判断当前请求是否为post请求
```
if(!function_exists('is_post'))
{
function is_post()
{
return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='POST';
}
}
```
## GET
函数用来判断当前请求是否为get请求
```
if(!function_exists('is_get')){
function is_get()
{
return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='GET';
}
}
```
## AJAX
函数用来判断当前请求是否为ajax请求
```
if(!function_exists('is_ajax')){
function is_ajax()
{
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtoupper($_SERVER['HTTP_X_REQUESTED_WITH'])=='XMLHTTPREQUEST';
}
}
```
## CLI
函数用来判断当前请求是否为cli模式
```
if(!function_exists('is_cli')){
function is_cli()
{
return (PHP_SAPI === 'cli' OR defined('STDIN'));
}
}
```