#native_company# #native_desc#
#native_cta#

Beginner Debugging: For Your Eyes Only Page 5

By John Starkey
on October 30, 2002

If you prefer to recieve the data via email, you can always build your message throughout the script and at
the end, use the mail() function:

<?php

if ( $debug_ok == mail'[email protected]''It's broke!!!'$message );

?>



Doing things this way will also prevent the risk of accidentally sending your data to the wrong browsers.
If you prefer to log your data, you can do:

<?php

if ( $debug_ok == trigger_error'Your debug data here' );

?>



This requires that you have logging set up on the server. You can find more info on logging
here.
There are many other options available to you. The above code leaves a lot of room for customizing.
For instance, if you want to view only SQL data, you can assign $debug_ok a value of ‘2’ and if
$debug_ok == 2 then show the SQL data.

Summary

It’s never a good idea to allow your errors to be viewed by the masses. By coding in your debug requirements
early on, you will cut down on the amount of time it takes to debug your code. Of course, each time you add
code to your site, you’re slowing it down a little at a time. So, it’s imperitive that you think out your
debug strategy far in advance, using as little code as possible to get the most specific amount of data.

1
|
2
|
3
|
4
|
5