header('Location: ' . $url);
我檢查了,沒有以前的輸出:以前沒有輸出,但頭重定向不在PHP工作
ob_start();
...
var_dump(ob_get_contents());
ob_flush();
header('Location: ' . $url);
輸出:
string '' (length=0)
那麼爲什麼用重定向失敗?
儘管我在error_log
中看到很多警告和通知,但只要它不向瀏覽器輸出任何內容,就不會影響header()
,對不對?
UPDATE
一些日誌(不應雖然有關):
[Wed May 19 00:26:10 2010] [error] [client 127.0.0.1] PHP Deprecated: Function eregi() is deprecated in D:\\Works\\general
[Wed May 19 00:26:10 2010] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://localhost/cookie_usage.php
[Wed May 19 00:26:10 2010] [error] [client 127.0.0.1] PHP 1. {main}() D:\\Works\\login.php:0, referer: http://localhost/cookie_usage.php
[Wed May 19 00:26:10 2010] [error] [client 127.0.0.1] PHP 2. tep_redirect() D:\\Works\\login.php:33, referer: http://localhost/cookie_usage.php
取決於,也許你可以顯示警告? – 2010-05-18 16:03:49
$ url爲空。註釋必須至少包含15個字符。 – 2010-05-18 16:07:08
你確定$ url不是空的嗎? – webbiedave 2010-05-18 16:08:33