Is there any way to know if a php script is running in cli mode?

前端 未结 4 1968
悲&欢浪女
悲&欢浪女 2021-01-11 18:39

... or the other way around, is there any way to know if a php script is running inside a web server?

4条回答
  •  囚心锁ツ
    2021-01-11 18:43

    http://www.php.net/manual/en/function.php-sapi-name.php

    function is_cli()
    {
        return php_sapi_name() === 'cli';
    }
    

提交回复
热议问题