1

我有这个代码:

<?php
    //Search logic for Holiday.GE
    $search_variables = $_GET['s']. '+' .$_GET['cat'];
    $var_lang_now = $_GET['lang_current_search'];

        if ($var_lang_now == ru OR $var_lang_now == en) {
            $refering_page = 'http://dev.holiday.ge/' . $var_lang_now . "/";
        } else {
            $refering_page = 'http://dev.holiday.ge';
        }

    //This sends http post to url without curl
    header("Status: 301 Moved Permanently");
    header("Location:$refering_page?s=$search_variables");
    exit;
?>

在我测试它的本地主机上运行良好。但是在实时服务器上,它会出错:

Warning: Cannot modify header information - headers already sent by (output started at /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php:3) in /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php:3) in /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php on line 16

15和16是出口前的线路;

我按照答案中的建议尝试了,但我得到了同样的错误!

<?php
ob_start();

    //Search logic for Holiday.GE
    $search_variables = $_GET['s']. '+' .$_GET['cat'];
    $var_lang_now = $_GET['lang_current_search'];

        if ($var_lang_now == ru OR $var_lang_now == en) {
            $refering_page = 'http://dev.holiday.ge/' . $var_lang_now . "/";
        } else {
            $refering_page = 'http://dev.holiday.ge';
        }

    //This sends http post to url without curl
    header("Status: 301 Moved Permanently");
    header("Location:$refering_page?s=$search_variables");
    exit;

ob_end_flush();
?>
4

3 回答 3

1

放在ob_start();开头,ob_end_flush();结尾

于 2012-10-03T12:11:41.100 回答
0

在脚本开始时使用它

ob_start();

最后是这个

ob_end_flush();

它将解决这个问题。前段时间我在插入这些之后遇到了同样的问题,一切都很好。

header("Location: $refering_page?s=$search_variables");
                 ^ //space should present.
于 2012-10-03T12:12:28.653 回答
0

请在页面顶部使用此代码:

<?php ob_start(); ?>

和下面的代码页面底部

<?php ob_flush(); ?>
于 2012-10-03T12:13:10.153 回答