PHP vérifie si CLI

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