tags:

views:

154

answers:

3

I have the following script

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

?>

The output that I get is

I am alive
I am dying

Is there any way (alternative/substitute of die()) using which the execution of the remaining script be continued?

EDIT :

Sorry I have got what I wanted and have voted to close the question. Please neglect the question.

A: 

If you want to run script after result is returned to the user try this:

    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
Piotr Pankowski
+1  A: 

You can use trigger_error:

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

Output:

I am alive
Notice: I am dying in ... on line 3
Dead 
Jani
+6  A: 

If the motives behind your question lie with error handling you might want to have a look at try/catch structures in PHP.

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

calumbrodie