views:

44

answers:

3

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

A: 

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
A: 

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: http://stackoverflow.com/questions/216963/fastest-way-to-determine-where-php-script-exits .

Alin Purcaru
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
A: 

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