1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/** *@todo: 判断是否为post */ if(!function_exists('is_post')){ function is_post() { return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='POST'; } } /** *@todo: 判断是否为get */ if(!function_exists('is_get')){ function is_get() { return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='GET'; } } /** *@todo: 判断是否为ajax */ if(!function_exists('is_ajax')){ function is_ajax() { return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtoupper($_SERVER['HTTP_X_REQUESTED_WITH'])=='XMLHTTPREQUEST'; } } /** *@todo: 判断是否为命令行模式 */ if(!function_exists('is_cli')){ function is_cli() { return (PHP_SAPI === 'cli' OR defined('STDIN')); } } |
from:https://blog.csdn.net/wujiangwei567/article/details/72772783