それを呼び出した後、これをキャンセルすることが可能です:(リフレッシュ)ヘッダをキャンセル
<?php
// Start output while creating profile
if (ob_get_level() == 0) ob_start();
for ($i = 0; $i<1; $i++)
{
// Redirect user and download the profile
header('Refresh: .02; download.php');
echo "You're profile is being created, please wait...";
ob_flush();
flush();
sleep(1);
}
ob_end_flush();
// Start creating the profile
// Start this after the code above due to the long execution time
if(!createProfile())
{
// If createProfile returns false, cancel redirect and stop execution
cancelRedirect();
// Inform the user about the problem
echo 'Error!';
exit;
}
?>
意図がheader()
-functionが呼び出されるということである、スクリプトが何かをして、期待通りの結果ではない場合「download.php」へのリダイレクトをキャンセルする必要があります。
論理的には、それは意味がありません。 – Marcus
それは 'header()'関数を呼び出す前に 'echo'が動作しないため、これを行う唯一の方法です。 – alve89
しかし、 'header_remove()'はあります。 – mario