Well, when I am debugging a huge PHP file, I do the following:
1) I set $DEBUG="YES" at the beginning of my php file
2) then, every place I need to echo data for tracing, instead of a simple echo, I put the following: if ($DEBUG=="YES") echo "Variable xyz is value $xyz <br />";
3) Once I'm done debugging, I simply set $DEBUG="NO" at the beginning of the file.
It works well, if you don't mind spending a few extra CPU cycles...