我如何知道php中的位置是标头还是非标头?
请看我的代码如下:
<?php
// how can i check the position is header of not?
// header = no html outputed yet before test() run
// not_header = there is some html outputed before test() runed
function test(){
$is_header=???;
if($is_header){
echo 'is_header';
}else{
echo 'not_header';
}
}
test(); // 'is_header'
?>
hello world .... html outputed
<?php
test();// 'not_header'
?>
发布于 2014-03-03 09:55:59
看看已发送。通常,您应该添加带有标题函数的标头,因此很少需要找出是否已经发送了标头。同样值得在这个上下文中阅读的是用于输出缓冲的运行时配置。
https://stackoverflow.com/questions/22143463
复制相似问题