我如何知道php中的位置是否为页眉?

我如何知道php中的位置是否为页眉?,php,Php,我如何知道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($

我如何知道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'
?>

你好,世界。。。。输出的html

看一看。通常,您应该使用函数添加标题,因此很少需要了解标题是否已经发送。在本文中,同样值得一读的是。

可以使用?正如其他人已经提到的那样:查看用于此类测试的phps
header\u sent()
函数。但是请注意,如果你真的必须在脚本的某个地方进行测试,那么很有可能你的体系结构存在严重的问题。问问自己,为什么你必须在加工过程中找出这样的东西。