PHP Periksa apakah CLI

function isCommandLineInterface()
{
    return (php_sapi_name() === 'cli');
}
Alexander Matzen