Setting and accomodating for a debug flag is one of the easiest ways to turn your script or application into "debug mode". One such method is to allow for a dedicated query string parameter, say debug, where in it's presence, your script runs in "debug mode".
Using a ColdFusion example, let's say we want to alter the conditions of a query based on the presence or lack-of the query string debug parameter. The example query selects a list of all users in a database table, in preparation for a mass email. In this situation, a system for simple debugging is crucial.
SELECT fname, lname, email
<cfif isDefined("url.debug")>WHERE email = 'email@example.com'</cfif>
Now, all code in your script, which depends on the users recordset, will only be referencing the "debug" version of the query.