【发布时间】:2011-12-29 20:34:27
【问题描述】:
可能重复:
What is the canonical way to determine commandline vs. http execution of a PHP script?
我正在编写一个将作为 cron 作业执行的小脚本。有没有办法了解这个脚本是否是从 Web 服务器调用的,以便我可以回显 <br /> 而不是换行符作为输出?
【问题讨论】:
-
最好的办法是发送
header('Content-type: text/plain');并发送换行符。 -
@Truth no,你可以通过
php_sapi_name()或PHP_SAPI来确定
标签: php