【发布时间】:2014-08-14 19:26:49
【问题描述】:
所以我有这个代码:
<?php
// Set headers
if (!headers_sent()) {
header('Content-Type: text/html; charset=UTF-8');
header('Content-Style-Type: text/css');
header('Content-Script-Type: application/javascript');
header('HTTP/1.1 200 OK');
header('Content-language: en-US');
header('X-Powered-By: ');
header_remove('X-Powered-By');
header('Last-Modified: Tue, 01 Jan 2013 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, max-age=0, must-revalidate');
header('Pragma: no-store, no-cache, max-age=0, must-revalidate');
header('Expires: Tue, 01 Jan 2013 00:00:00 GMT');
exit(0);
}
添加exit(0); 后,我的页面完全空白。没有 HTML。任何想法为什么?我应该使用exit(0); 吗?它用于php.net 上的其中一个示例。此外,如果我删除exit(0),整个页面看起来还不错。
【问题讨论】:
-
exit() 退出,所以您只需发送标头
-
所以你的意思是我不应该使用它?
-
您应该在可以退出时使用(可能不仅仅是在发送标头之后)。
-
可能在脚本文件的末尾?
标签: php if-statement http-headers exit