質問

次のスクリプトがあります

<?php
      echo "I am alive<br>";
      die("I am dying<br>");
      echo ("Dead");

?>

私が得る出力はです

I am alive
I am dying

方法はありますか(代替/代替品 die())残りのスクリプトの実行が継続されるものを使用しますか?

編集 :

申し訳ありませんが、私は自分が望んでいたものを手に入れ、質問を閉じるために投票しました。質問を無視してください。

役に立ちましたか?

解決

あなたの質問の背後にある動機がエラー処理にある場合は、PHPのTry/Catch構造を見てください。

http://php.net/manual/en/language.exceptions.php

他のヒント

使用できます 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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top