In instance where I find myself wanting to use a global variable, I often give myself permission to use a static function instead. So instead of
global $verbose;
if ( $verbose ) { ... }
I do
function verbose($status = NULL) {
static $current_status;
if ( is_bool($status) ) {
$current_status = $status;
}
return $current_status;
}
This basically accomplishes the same thing; is it any better or as bad as using global variables?