如何摆脱PHP脚本输出中的“内容类型:文本/html”


How to get rid of 'Content-type: text/html' in PHP script output?

我正在将PHP脚本作为cron作业运行。如果脚本生成输出,则会触发电子邮件。不幸的是,即使它没有输出任何内容,也会触发一封电子邮件:

Content-type: text/html

如何摆脱这种触发电子邮件的自动Content-type: text/html生成?

使用 php 命令上的-q开关:

php -q whatever.php

这代表"安静",将阻止 php 输出通常的 Web 标头。

或者,如果要显式且更详细,可以使用--no-header

php --no-header whatever.php

来源:PHP 手册:命令行选项