RE: looking for php debugging tips

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
This may help, depending on your preferences. Anyway, it's what I have used for some years now both on ASP and PHP development.
On the server-side use a dedicated variable (eg. $dbg) to dump any value/variable you want to check/trace.
On the client-side create a hidden <input> field with the value set to $dbg (<input type="hidden" id="cs_dbg" name="cs_dbg" value="<?= $dbg ?>">)
Then somewhere on the page where users are not likely to double-click, usually I use the header bar, create an invisible field with the onDblClick event handler pointing to some function that formats the data from cs_dbg and displays it in a message box.
In IE you can use a <span> tag with inline style, e.g.
<span id="spnDbg" style="position:absolute; top:2px; left:760px; width:20px; height:20px; visibility:hidden;" onfiltered="return spnDbg_ondblclick()"></span>
In other browsers you'll have to use a button, since some browsers don't support events attached to <span> elements, but the principle is the same.
Example code for event handler:
<script type="text/_javascript" language="_javascript">
 
function spnDgb_ondblclick() {
var strT="", someArr = new Array();
.....
//parse the data from cs_dbg here
//eg. explode to array and extract name-value pairs
//or whatever ...
.....
strT += "someVar: " + someArr["someVar"] + "\n";
.....
window.alert(strT);
}//end
 
</script>
 
Obviously you can include client-side variables to be displayed too.
When you need to check the variables, double-click on the hidden debug spot and there you go. Once you have finished the dev stage of the application, wipe the code and hidden field.
 
Needless to say, you'll have to adapt language/tags etc to your particular environment, but the above has saved me hours of frustration.
 
Cheers,
 
Jennifer




"Svensson, B.A.T. (HKG)" <B.A.T.Svensson@lumc.nl> wrote:With scripting languages: print is your best friend!

Also check out ww.php.net, they gives soem references to some remote
debuggers wich seams to be usefull. I haven't tested them yet thou. 

-----Original Message-----
From: Jim MacDiarmid
To: php-windows@lists.php.net
Sent: 2004-01-08 03:07
Subject:  looking for php debugging tips

Can anyone help out a newbie or point me in the right direction on
properly debugging php code? I'm really having a rough time with this,
and things just don't seem to be working the way I'm expecting them to.
I'm trying to study this by using the "Teach yourself php, mysql, and
apache in 24 hours" and it appears there are a lot of errors in the
book, which is adding to my confusion.

Many thanks
Jim



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




---------------------------------
Yahoo! Personals
- New people, new possibilities. FREE for a limited time!

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux