Saturday, July 11, 2009

Stopping PHP Script Execution

Do you know all the ways of stopping PHP script execution? Put your knowledge to a test with this question from the Zend PHP 5 Certification Mock Exam.

The question is as follows. Correct answers in bold.
What would go in place of ?????? below to make this script execute without a fatal error?

$a = 1;
$b = 0;


$c = $a / $b;
  • quit();
  • die();
  • stop();
  • __halt_compiler();
  • exit();
die() and exit() are quite obvious, stop() and quit() do not exist and what about __halt_compiler()? The latter was introduces in PHP5. Manual page says it stops the execution of the compiler and nothing after this call is executed.


  1. I've never heard this about __halt_compiler :)

  2. You mean "stop() and quit() do not exist"....

  3. Yes, you are right Jon. Thanks for that. I have already changed that.

  4. Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.