小白教程
所有教程
关于
Search
172.69.6.2
172.69.6.2
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func http headers sent”的源代码
本页内容
上一节:
Func_http_headers_list
下一节:
Func_http_setcookie
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:headers_sent()}}[[Category:PHP HTTP 参考手册|3]] = PHP headers_sent() 函数 = [[Category:PHP HTTP 参考手册]] == 定义和用法 == headers_sent() 函数检查 HTTP 报头是否发送/已发送到何处。 如果报头已发送,该函数返回 TRUE,否则返回 FALSE。 == 语法 == <pre> headers_sent(file,line) </pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | file,line | 可选。如果设置 file 和 line 参数,headers_sent() 会把输出开始的 PHP 源文件名和行号存入 file 和 line 变量中。 |} == 提示和注释 == '''注释:'''一旦报头块已经发送,您就不能使用 header() 函数来发送其它的报头。 '''注释:'''可选的 file 和 line 参数是 PHP 4.3 中新增的。 == 实例 1 == <sample title="" desc="" lang="php" hererun="1"> <?php // If no headers are sent, send one if (!headers_sent()) { header("Location: http://www.w3cschool.cc/"); exit; } ?> <html> <body> ... ... </sample> == 实例 2 == 使用可选的 file 和 line 参数: <sample title="" desc="" lang="php" hererun="1"> <?php // $file and $line are passed in for later use // Do not assign them values beforehand if (!headers_sent($file, $line)) { header("Location: http://www.w3cschool.cc/"); exit; // Trigger an error here } else { echo "Headers sent in $file on line $line"; exit; } ?> <html> <body> ... ... </sample> [[Category:PHP HTTP 参考手册]]
返回至“
Func http headers sent
”。
上一节:
Func_http_headers_list
下一节:
Func_http_setcookie