We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

can we debug php code

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?

3
Contributors
6
Replies
1 Day
Discussion Span
4 Months Ago
Last Updated
7
Views
Question
Answered
arti18
Posting Whiz in Training
207 posts since Dec 2012
Reputation Points: 2
Solved Threads: 25
Skill Endorsements: 0

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

riahc3
 
Team Colleague
1,304 posts since May 2008
Reputation Points: 62
Solved Threads: 13
Skill Endorsements: 11

This link might help you a bit.

broj1
Nearly a Posting Virtuoso
1,212 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13

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

broj1
Nearly a Posting Virtuoso
1,212 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13

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

arti18
Posting Whiz in Training
207 posts since Dec 2012
Reputation Points: 2
Solved Threads: 25
Skill Endorsements: 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.

broj1
Nearly a Posting Virtuoso
1,212 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13

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

arti18
Posting Whiz in Training
207 posts since Dec 2012
Reputation Points: 2
Solved Threads: 25
Skill Endorsements: 0
Question Answered as of 4 Months Ago by broj1 and riahc3

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0741 seconds using 2.68MB