對於大家都在想的error_reporting()函數,那麼它是不是,我需要的是每當MySQL查詢已經完成,並聲明有一個像好的錯誤標記| PHP
if($result)
{
echo "Yes, it was fine... bla bla";
}
else
{
echo "Obviously, the echo'ing will show in a white page with the text ONLY...";
}
每當陳述是真實的或false,我希望在使用header()函數重定向時出現錯誤,並在頁面某處的div中回顯錯誤報告。
基本上是這樣的:
$error = '';
這部分出現在div標籤
<div><?php echo $error; ?></div>
因此,當與頭部()
if($result)
{
$error = "Yes, it was fine... bla bla";
header("Location: url");
}
else
{
$error = "Something wrong happened...";
header("Location: url");
}
重定向錯誤的部分將被回波內
但這只是不起作用:(
請記住,http是一個請求/響應協議。因此,您的腳本正在使用Location標頭進行響應(並且基本終止),並告訴瀏覽器向您的應用程序(或URL所指向的任何位置)發出* new *請求。 $ error中的當前值僅在當前請求中可用,而不是在新請求中。 – 2010-04-16 23:54:25