-1

I was wondering if there was a way to know where the script stopped (ie: file + line), which would be useful for debugging or for removing stupid 'exit' calls lost somewhere in the code.

Thanks in advance

HappyDeveloper
  • 12,480
  • 22
  • 82
  • 117
  • what do you mean - stopped? for what reason? If it's because of some error, there is always a line number already in the error message. – Your Common Sense Oct 19 '10 at 15:36
  • Knowing the reason is one of the points of knowing where it stopped. I know that errors tells the line number, get serious pls. If the script stopped because of an 'exit()' call with no arguments, it won't say anything. – HappyDeveloper Oct 20 '10 at 14:19

3 Answers3

1

Wrong (and I'm sorry for not testing it first): You could use register_shutdown_function in conjunction with debug_backtrace.

See here for a duplicate of your question: Fastest way to determine where PHP script exits .

Community
  • 1
  • 1
Alin Purcaru
  • 43,655
  • 12
  • 77
  • 90
  • 1
    I thought of that, but have you ever tried that? I only get 1 trace, and is not useful at all. Seems like it is called from outside the call stack – HappyDeveloper Oct 19 '10 at 16:07
0

If you want to remove exit from the script, try using PHP Code Sniffer PEAR package http://pear.php.net/package/PHP_CodeSniffer

Just create a sniffer to find out where all the exits are in the code (you get a report of file and line).

If you want to find out what line a script stopped at, use a debugger and you can get a stack trace to find out the last line a script executed too (Xdebug is easy to use and set up). Any debugger is going to severely hinder performance as it needs to manage more memory.

MANCHUCK
  • 2,424
  • 1
  • 16
  • 22
0

I'm not sure what IDE your using (if any), but this would be trivial using xdebug. I personally use it with netbeans and it works great although it is a bit tricky to setup. It will let you walk through your code step by step and show exactly where it is exiting.

ozruiz
  • 43
  • 4