Easier debugging
there are many ways to make debugging much easier! the most basic one is setting your error reporting level to a higher one, specifically talking about reporting notices. errors of type E_NOTICE will make it easier for you to find variables that you have misspelled which will save you time from going over the whole file looking for what’s causing the problem. you can change the error reporting level in php.ini or in run-time by using the function error_reporting() which takes the new level and returns the old one.
another method is assertion by using the function assert(). the argument passed to assert() can be either a boolean value or a string which will be evaluated. if the assertion failed, a warning will be issued. the beauty of assert() is that you can disable all assertions when preparing the script for release without the need to remove them from your script by setting assert_options(ASSERT_ACTIVE, 0) .
another elegant solution is UnitTesting which is more advanced and is Object-Oriented. my favorite framework is SimpleTest by Marcus Baker which has neat features like mock objects and web navigation. I’ll write about UnitTesting using SimpleTest framework in the next newsletter. stay tuned ;)
Saleh Jamal
http://www.phpsimplicity.com
(Published in 24-4-2005 for Hotscripts.com newsletter - April issue)