标头位置在php 5.3.21中不起作用

时间:2013-02-14 08:46:19

标签: php header location switch-statement

我的标题位置无法在使用php 5.3.21的服务器上运行。它适用于5.4.7的本地主机。它向后兼容..任何人都可以告诉我为什么这是错的?

switch ($table) {
    case "hardcover":
    header('location:hardcover.php?type=Aanvraag&relID='.$relID.'');
    break;
} 

它是一个开关案例的一部分,决定从HTML选项列表输入特定值后的去向。当我在同一个案例中回显$relID$table时,它会回显这些项目。但不知怎的,它不会重定向到标题..

结果来自:ini_set("display_errors", "On");

Warning: Cannot modify header information - headers already sent by (output started at /customers/f/f/e/tdmdev.nl/httpd.www/graficrm/htmlheader.php:7) in /customers/f/f/e/tdmdev.nl/httpd.www/graficrm/aanvradd.php on line 47

第47行是标题所在的行。 第7行是会话回显到html标题区域的地方。

2 个答案:

答案 0 :(得分:1)

在页面开头尝试ob_start()

答案 1 :(得分:0)

switch ($table) {
    case "hardcover":
    header('Location:hardcover.php?type=Aanvraag&relID='.$relID.'');
    exit();   // <-stop and allow header to do its thang!
    break;
}