1 我想你可以使用函數php_sapi_name()並檢查'cli'來檢查它是否從cli調用。 php_sapi_name() == 'cli' http://in2.php.net/php_sapi_name 來源 2014-03-19 12:39:43 Ramesh