Chau Chee Yang
Chau Chee Yang

Reputation: 19600

How do I stop execution at the middle of PHP script that return success status?

I am running the following php script via web browser:

<?php
  require_once("test.php");
  ....
  exit(0);
  ....
  require_once("test2.php");
  ....
?>

I am debugging my php script. I want the script to stop execute some where at the line of "exit(0)". However, the php doesn't execute successfully. If I remove "exit(0)" then it works.

How may I stop the PHP script execution in the middle?

Upvotes: 2

Views: 714

Answers (1)

VAShhh
VAShhh

Reputation: 3504

For the only purpose of debugging you can use the die() method so you will have

<?php
  require_once("test.php");
  ....
  die("killing the execution");
  ....
  require_once("test2.php");
  ....
?>

But you must remember that the code after the die will not be executed. The only way to "pause" the execution of a PHP is by using a debugger like xdebugger or Zend_Debugger

Upvotes: 2

Related Questions