私は次のスクリプトを持っています
<?php
echo "I am alive<br>";
die("I am dying<br>");
echo ("Dead");
?>
私が得る出力は
I am alive
I am dying
die()残りのスクリプトの実行を継続する方法(の代替/代替)はありますか?
編集:
申し訳ありませんが、私は欲しいものを手に入れ、質問を閉じることに投票しました。質問は無視してください。
質問の背後にある動機がエラー処理にある場合は、PHPのtry/catch構造を確認することをお勧めします。
trigger_errorを使用できます:
<?php
echo "I am alive<br>";
trigger_error("I am dying<br>");
echo ("Dead");
?>
出力:
I am alive
Notice: I am dying in ... on line 3
Dead
結果がユーザーに返された後にスクリプトを実行する場合は、次のことを試してください。
while (ob_get_level () != 0) {
ob_end_clean ();
}
header ("Connection: close\r\n");
header ("Content-Encoding: none\r\n");
ignore_user_abort (true);
ob_start ();
// do stuff that should be returned here
header ("Content-Length: ".ob_get_length ());
ob_end_flush ();
flush ();
// do rest here