Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Developer Tutorials:
Debugging PHP code using debug_backtrace
Feb 29, 2008 @ 16:27:00

On the Developer Tutorials blog today, Hasin Hayder has pointed out a handy PHP function that can make your debugging a bit less of a headache - debug_backtrace.

Most of the PHP developers debug php code in their local machine just by trial and error using "print_r","var_dump" and "echo". They don't write unit tests or follow any advanced debugger like xdebug. But the problem of using these methods is you cannot fool proof your code and their might be some bugs still present in your code.

He includes a simple example to show how it works and what kind of output it will give - a nested function call. Personally, I use this in some of my classes (like a database abstraction later) to track and see which functions my calls are coming from and what data they're sending me - easier to debug in one place than trying to guess.

tagged: debugbacktrace debug example simple

Link:

Nick Halstead's Blog:
Programming Tips #9 "debug_backtrace"
Feb 11, 2008 @ 16:33:00

Nick Halstead continues the "Programming Tips" series on his blog today with tip number nine (a very handy tip indeed) - using debug_backtrace from Larry Garfield.

Despite the proliferation of debugging tools, especially real-time debuggers, "debugging by print statement" remains the most common form of debugging in most programming languages.

An example of its use is included by way of a debug() function that returns the message it a bit friendlier format.

tagged: debugbacktrace error debug programming tip

Link:

Nick Halstead's Blog:
Programming Tips #9 "debug_backtrace"
Dec 19, 2007 @ 14:42:00

Nick Halstead has posted the latest programming tip to his blog today (as written by LArry Garfield) concerning the use of debug_backtrace.

Despite the proliferation of debugging tools, especially real-time debuggers, "debugging by print statement" remains the most common form of debugging in most programming languages. [...] Fortunately, PHP offers another debugging tool: debug_backtrace(). It returns an array that is a complete function stack up to the point it is called.

Larry includes a basic example of the function in use - a debug() function that takes in a message, label and a "stealth" setting and outputs a formatted result of the debug_backtrace output.

tagged: programming tip debugbacktrace output example programming tip debugbacktrace output example

Link:

Nick Halstead's Blog:
Programming Tips #9 "debug_backtrace"
Dec 19, 2007 @ 14:42:00

Nick Halstead has posted the latest programming tip to his blog today (as written by LArry Garfield) concerning the use of debug_backtrace.

Despite the proliferation of debugging tools, especially real-time debuggers, "debugging by print statement" remains the most common form of debugging in most programming languages. [...] Fortunately, PHP offers another debugging tool: debug_backtrace(). It returns an array that is a complete function stack up to the point it is called.

Larry includes a basic example of the function in use - a debug() function that takes in a message, label and a "stealth" setting and outputs a formatted result of the debug_backtrace output.

tagged: programming tip debugbacktrace output example programming tip debugbacktrace output example

Link:


Trending Topics: