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 dont 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. Lets see how can we debug our code more effectively getting more information from the php interpreter itself. There is a nice function called debug_backtrace() is available in PHP to trace the root of an error. As the name implies, you can trace the execution of you code which produces the error. Have a look at the following code.
function processUserInput($a, $b)
function divide($c, $d)
This will output the following one
Array (  => Array ( [file] => PHPDocument1 [line] => 5 [function] => divide [args] => Array (  => 4  => 0 ) )  => Array ( [file] => PHPDocument1 [line] => 14 [function] => processUserInput [args] => Array (  => 4  => 0 ) )  => Array ( [file] => /home/hasin/Zend/ZendStudio-5.5.0/bin/php5/dummy.php [line] => 1 [args] => Array (  => PHPDocument1 ) [function] => include ) )