运行 PHP 脚本 cron 作业时什么被视为输出?

运行 PHP 脚本 cron 作业时什么被视为输出?

我正在运行一个 PHP 脚本,该脚本使用 cron 作业每分钟在数据库中插入行。

我的供应商说:

An email will be sent to this address ONLY if your cron produces output.
If no output is generated, then no email will be sent.

只有在出现查询错误时,我才会在 PHP 中发出 echo 语句。但我没有遇到错误,而且我看到数据库中出现了这些行。

然而,即使没有错误,我仍然会收到(几乎)空内容的电子邮件:

Content-type: text/html

我该如何防止这种情况发生?运行 PHP 脚本 cron 作业时什么被视为输出?

更新

为了摆脱标题,请参阅:https://stackoverflow.com/questions/10723546/how-to-get-rid-of-content-type-text-html-in-php-script-output

答案1

header代码中是否有任何调用?<?php ... ?>块外是否有空格?回答您的问题“输出”是指在非 CLI 操作中发送到浏览器的任何内容,例如您看到的 HTTP 标头。

相关内容