1.11M Members

can we debug php code

 
0
 

i am just start to learn php and using dreaweaver for practice, i just want to know that like other languages can we debug php code if can then how we debug php code in dreamweaver or any other editor for php?

 
0
 

Id start with FirePHP and tell us if thats good enough or if something is missing...

 
0
 

This link might help you a bit.

 
0
 

Maybe a word or two also on a poor man's debugging technique. When you quickly want to examine values of variables you just insert an echo or die statement after the point in code that interests you. When examining simple values (strings, integer, floats...) just use echo (or die if you also want to stop the execution). If you want to examine arrays or objects then you add a little bit of formatting and use print_r function (with second parameter set to 1 to use the output in echo):

$myArray = array('key1' => 'value1', 'key2' => 'value12);
echo '<pre>' . print_r($myArray, 1) . '</pre>';

You can also send output into html code only in a form of a html comment:

echo '<!-- ' . print_r($myVar, 1) . ' -->';

This way the debug output won't interfere with displayed page, it will be included in source code of the page only (in Firefox then you just right click and select View page source).

 
0
 

i know echo and die method but what can we do if they also not work hoe to find error if echo and die not helpping is there any way to interpret php code line by line

 
0
 

Echoing should work in most cases if you put echo in correct place which can be sometimes tricky. Take in account included files and functions, ajax calls etc. And have all error reporting enabled while you are debugging.

There is also a comprehensive debug tool called xdebug. I have never used it but have seen some demos and it seems that might be what you are after. But I think it requires a little bit of learnig to start using it.

 
0
 

ok broj1 i will give a try to xdebug i m also hear about these and i try to use firephp add-ons in firefox but don't know how to use after installing

Question Answered as of 1 Year Ago by broj1 and riahc3
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: