PHP prüfen, ob CLI

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