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?

Recommended Answers

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

Jump to Post

This link might help you a bit.

Jump to Post

All 6 Replies

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

This link might help you a bit.

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).

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.