Forum Moderators: coopster
Just learning php/mysql and have used it to set up things like a contact form on my web site. I have Dreamweaver MX but am hand coding the php code.
Is there a good free tool I could use to speed up debugging of php? I waste quite a bit of time debugging basic mistakes like missing periods or quote marks.
I like the Dreamweaver Validate HTML markup tool, I just wish it had a similar tool for PHP
Thanks all
- editor with syntax highighting and brace/paren matching. This iwll help with real obvious things like not closing a quoted string.
[webmasterworld.com...]
[webmasterworld.com...]
- there are also a variety of debuggers, most of which, in my experience, provide little additional information (in part because I just can't get most of them to run). Search google on
"php debuggers"
"php debuggers dbg"
"php debuggers xdebug"
and see what you get. I sort of got xdebug to work and many people seem to get dbg to work.
[phpedit.net...]
I have found a few editors that are much less ambitious, but at least get things working before moving on to the next thing. That said, if I could ever get the phpEdit/dbg debugger working, I would consider using it.
Also, I've sent in so many feature requests, bug reports and corrected translations the interface, etc., that I'm starting to feel like I need a disclaimer when I recommend it (by which I mean a disclaimer saying that I feel "connected" not a disclaimer saying I don't recommend it - it's the least buggy freeware editor I've found that has syntax highlighting).
It works for me and it's my favorite, but I've also tried and liked context, xored, kommodo, and others. Mostly anything that's relatively bug free and relatively small, with line numbering and preferably syntax highlighting is okay by me.
[edited by: ergophobe at 9:22 pm (utc) on May 13, 2004]
<?php
/*
the debug unit (aka. "du")a simple debug function, outputs stuff to a file
the *concept* of this is much more important than the code
once you get serious about a project, you need to get information.
a wee debug system can save you a lot of trouble. you can have your
debug information just there, rather than echoing $hite all over your
page, which people do, and I used to, too.
any good text editor will update when files do (BBEdit, TextPad, etc)
this made tuning corzoogle's scoring mechanisms a great deal easier.
sometimes I had the readout in a tab of my web browser
call
debug(out)
to finalise (and output) the debug information to the .out file
you can do this at any point, and any number of times, useful if
you need to check a value before or during some long operation.
notes..
the // :debug:comments allow you to remove ALL debug lines at once
(with a decent text editor, or grep)
I also find it useful to keep my debug lines hard-left regardless of the
current indentation.
all the scripts in my php test folder use the same debug.out file
there's one in this source folder, where I work on these scripts, try it.
*/
//examples..
debug("\nstarting debug output for du.php..\n");// :debug:
/* //:debug:
// get all the server variables.. //:debug:
while (list($key, $val) = each($_SERVER)) { //:debug:
debug($key.chr(9).$val."\n"); }//:debug:
debug("\n\n");//:debug:
*///:debug:
$string = 'colours';
$array = array('yellow','orange','green','blue');
debug('these are "'.$string.'"'."\n\n");// :debug:
debug(print_r($array, true)."\n");// :debug: - wont work @ my web host, needs >= php4.3
if(count($array) > 0) debug('number of colours? = '.count($array)."\n"); // :debug:
echo '<html><body><center>putting debug information here on the page is real nasty!<br>';
echo '<a href="debug.out" title="check out the info!">check this instead</a></center>
</body></html>';
/*
function:debug()
*/
function debug($data) {
global $debug_string; // make global too, if you like
if($data == 'out') {
$debug_string .= "\n\n";
if(file_exists('debug.out')) {
$debug_file = fopen('debug.out', 'w');
fputs($debug_file, $debug_string);
fclose($debug_file);
}
} else { $debug_string .= $data; }
}/*
end function debug()
*/
debug(out);// :debug://for something to read, you MUST end with this, or debug('out')
?>
hmm.. the code function seems dodgy here.
forgive the splurge, I would have posted a URL to this source, but TOS, you know..
;o)
(or
[edited by: jatar_k at 12:21 am (utc) on May 15, 2004]
[edit reason] removed url [/edit]
To get the debugger working you must go into preferences -> PHP Debugger -> CGI PHP executable
btw - The debugger is just something the PHPedit developers tacked on.
Thanks once again
debug(out); - feel free to mail/stickymail me about this. for actual coding, a decent text editor with proper syntax highlighting will go a long way towards helping you code more efficiently. if you have a mac, I recommend bbedit (bbedit is dreamweaver-savvy, and visa-versa), which has lots of real cute stuff I take for granted until I go to use a text editor on another platform, like the ability to double click any bracket and have it "balanced" - all the text inside the bracket becomes highlighted
saves me hours
;o)
(or