Page 1 of 1
debugging
Posted: Wed May 14, 2003 1:29 pm
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.
Posted: Wed May 14, 2003 1:40 pm
by m3mn0n
Posted: Wed May 14, 2003 7:29 pm
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>';
?>