Sponsored by HowLifeWorks
How Smart Guys Keep Their Faces Looking Young view!
howlifeworks.com - Why men have finally started to use certain anti-aging skin care products...
31 Comments
- daharveyjr, on 10/12/2007, -0/+1Very informative. Could save many hours of frustration trying to find that 1 simple bug.
- techie4life, on 10/12/2007, -0/+1im decent "know the basics" when it comes to PHP programming and I didnt even realize there was a program to step through-- this help a ton!
$digg++; - TheSiz, on 10/12/2007, -0/+1I can't believe a fourth of the article is dedicated to the complex usage of "THE PRINT STATEMENT". However, I wasn't familiar with PHPEclipse. I'll be sure to check that out.
- GTPilot, on 10/12/2007, -0/+1nothing wrong with beginning PHP stuff.
i think the print variables example is silly when you can do something like this:
function debug($var) {
echo"";var_dump($var);echo"";
}
re: "any decent developer should be using a debugging application such as eclipse or zend studio to step through their application"
any decent developer should also know that zend server isn't always available on the system you may be debugging on. even if it is, it's not the _only_ tool you should limit yourself to using. - atilio12, on 09/17/2009, -0/+1Debugging techniques for NLP programming in http://eHypnoticTrance.com .
- prazgod, on 10/12/2007, -0/+0I use Zend Studio and Zend Server daily for development and I know without it I would not be as good a PHP developer as I am. It makes everything so easy! (Im a professional 100% Income, fulltime PHP Developer)
You dont need Zend modules or plugins to run code you develop with Zend Studio. You only need the Zend Module (Optimiser) if you Zend encrypt your sourcecode. - fritzthecat, on 10/12/2007, -0/+0Bah, the Mac version of Eclipse is crap, so PHPEclipse is not an option for me. No digg!
- Rirath, on 10/12/2007, -0/+0Error messages and print statements are obvious... but I had not heard of PHPEclipse.
Might be just what I was looking for. - Shen, on 10/12/2007, -0/+0It's good, but it's no use strict; use warnings;
- etx313, on 10/12/2007, -0/+0Can you say... Duh? Eclipse it awsome btw, great for php, java, laszlo and flex! weee.
- debtman7, on 10/12/2007, -0/+0
I'd have to agree, eclipse on the mac does suck. I look at this stuff and think, hey that's cool! But then of course, you try to set things up on a mac and it's just dissapointing. Zend studio is similar, I never got the toolbar to work properly. I pretty much stick with the good old print statement method. JEdit on OS X works reasonably well and the php plugin will notify you of syntax errors. Works well enough. I don't find I need breakpoints and line stepping debugging with php often enough to make using a painful java editor on OSX worthwhile... - KAMI_no_kodomo, on 10/12/2007, -0/+0Thanks for telling me about Eclipse! That's just what i was searching for the last 6 months
- Gnascher, on 10/12/2007, -0/+0Yay ... yet another IDE to load on my machine, and another dissertation on the usefulness of the print() function.
Here's the article in a nutshell:
1. Sprinkle Print(); statements throughout your code at critical areas where data states change.
2. Checkout this nifty PHP plugin for the Eclipse IDE.
Here's another tip ... don't even have to click an article.
Create a little debugging class, and define a global variable called DEBUG. When you want to debug, you set this variable to true.
One of the accessor functions can be something like pringVar(), or printArray(), or printString() ... whatever. Basically, you put calls to these functions wherever critical state changes occur in your code. When you set DEBUT = true, these functions would print the variables you feed them ... set it to false, and they do nothing.
This way, you don't have to run around commenting out all your print() statements, or have that embarrassing situation where you forget to comment one out in a little-used execution path.
No Digg. You should know this stuff if you have good programming credentials ... if you don't ... go to school, and recommend this article to your prof. - Gnascher, on 10/12/2007, -0/+0Heh ... spelling surrenders.
DEBUG .. not DEBUT. But you can call it whatever you want ... just be consistant. :) - psytek, on 10/12/2007, -0/+0should read "Debugging techniques for PHP programmers using print statements, error reporting, and the PHPEclipse plug-in" no digg until that is corrected.
- spybreak, on 10/12/2007, -0/+0Debuggin techniques for Ruby On Rails programmers:
- breakpoint - rc_collins, on 10/12/2007, -0/+0lame. come on, this is "Welcome to PHP 101" stuff.
--dan - addi, on 10/12/2007, -0/+0gtpilot i was going to send inn the same code, only with print_r function.
- merlyn, on 10/12/2007, -0/+0Hmm. Sounds almost identical to my http://www.stonehenge.com/merlyn/LinuxMag/col76.html "Debugging Web Apps in Perl". I wonder if he read that, and wrote one about PHP? Or maybe just similar timing?
- loneBoat, on 10/12/2007, -0/+0^^ That's what I was going to say. ^^
Isn't this pretty standard stuff? Still Dugg, though. Eclipse is helpful. - sandrejev, on 10/12/2007, -0/+0If any part in that article is not obvious, maybe I could start considering myself as a genius. Seriously, how did author checked his scripts for errors before he wrote the article. And where are the real debugging tools. No way he's always doing that print stuff.
Perhaps what he really did wanted to write about is unit testing, or maybe something even more interesting - Superfluous, on 10/12/2007, -0/+0...isnt this how you test ANY programming language?
- GTPilot, on 10/12/2007, -0/+0lol, _MUCH_?
consider sometimes we may need to debug session, global, or other non get/post vars too.
tomatoe tomatoe ;) - coolbru, on 10/12/2007, -0/+0No-one has mentioned the xdebug PHP extension: xdebug.org. It adds much better error reports, local variable dumps, call stack traces, tracing, code coverage and profiling (output into kcachegrind which works great on OS X).
ZDE5 is fairly clunky - I dislike MDI interfaces at the best of times, and using one for development makes you feel like you're working through a keyhole. - a1programmer, on 10/12/2007, -0/+0I do something similar, just MUCH easier;
// at top
debug = true;
$P = $HTTP_POST_VARS;
$G = $HTTP_POST_VARS;
//bottom of page
if (debug){
print_r($G);
echo "";
print_r($P);
} - ThePharaoh, on 10/12/2007, -0/+0I code in ASP.NET and VB.NET and the practices are very similar. I can use print statements to determine where I am in code execution to help troubleshoot problem areas. Good find.
thepharaoh
http://www.freneticnetwork.com
http://www.frenetictech.com - znxster, on 10/12/2007, -0/+0nice enough .. +digg
- GTPilot, on 10/12/2007, -0/+0p.s. there is supposed to be PRE tags around that var_dump. they get stripped out here.
- jiminoc, on 10/12/2007, -1/+1any decent developer should be using a debugging application such as eclipse or zend studio to step through their application, dugg
- SubZ3r0, on 10/12/2007, -2/+1I got a debugging technique learn how to code and use apache and you wont have to worry bout this.... BTW Zend is gay and if you need extended modules like zend its cause your a noob.
- ipugh, on 10/12/2007, -1/+0"Debugging techniques for retards"
What is Digg?