Very newbie question. What is the best way to debug in php? What is the best way to see the value of your variables?

I'm coming from the Flash MX world, and in there, you can do a trace() and it traces out the value of your variables to the message window. PHP has print and echo but that seems to mess up the page layouts too much. Is there a way to print variables to a log file?

    What would be most helpful is to have an editor where you can debug as you are writing a script. If the script needs debugging then a few echo or print statement should not be too much of a bother, I mean if it is broke who cares about the page layout at least until the script work then remove the echo or print statement.

    Get an editor like PHP Designer and maybe put PHP and a server on your local machine. PHP Designer will show your script in a browser if you have PHP installed and will give you the errors when running so you can correct as you are developing a script without having to echo variables, unless of course you are getting variables that dont make any sense when the file runs.

    Basically you just need a good IDE to write and debug your programs, and PHP Designer is free, and even has an FTP client built in to quickly make changes to your web site right from the editor.

      Write a Reply...