debugging

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BillAngus
Forum Newbie
Posts: 1
Joined: Wed May 14, 2003 1:29 pm
Location: Vancouver area of BC, Canada

debugging

Post by BillAngus »

Is there a debugger I might use to inspect variable contents and branching in php code? Any other tools / examples that a novice developer should consider indispensible to app creation? I want to build a web/html-browser delivery system for tests (vocab tests, reading tests, etc.). I'm new to php programming.

Tx in adv.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Sorry if this is too obvious but things like:

echo '<p>$var=' . $var . '</p>';

..and..

print_r($array)

..can be inserted in scripts to do your own debugging (comment them on and off). That's all the debugging I find I need.

Also look at var_dump()

-------------------------------------
Write queries like this (to get an error message if they fail):

Code: Select all

<?php
$mysql = "SELECT * FROM table";
$query = mysql_query($mysql) or die("Cannot query the database.<br>" . mysql_error());
?>
-------------------------------------

If you want to time different methods:

Code: Select all

<?php
function getmicrotime(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}
$start = getmicrotime();

// code

$end = getmicrotime();
$time = $end - $start;
echo '<p>time = ' . $time . '</p>';
?>
Post Reply