function is_cli(){ return preg_match("/cli/i", php_sapi_name()) ? 1 : 0; } 转载于:https://www.cnblogs.com/waw/p/10167245.html