[plug] [OT] PHP Global DEBUG varible constant

Adam Ashley adam_ashley at softhome.net
Sun Aug 1 20:58:06 WST 2004


<?php  
    $DEBUG = 2;
    function capture_talk(){
       if ($_GLOBALS['DEBUG']) print "Debug is on<br>";
       if ($_GLOBALS['DEBUG'] >=2) print "Debug is on level 2<br>";
    }
?>

or if your not going to change the debug level once started executing

<?php
define('DEBUG', 2);

function printDebug() {
  print DEBUG;
}
?>

Adam

On Sun, 2004-08-01 at 17:08 -0400, Tim White wrote:
> Not sure what to put as the title.
> I am writing a PHP application which I wish to put debugging in. I 
> currently have a constant called 'DEBUG' that holds the debugging level. 
> I would like to be able to have a varible named 'DEBUG' or '$DEBUG' that 
> I don't have to worry about declaring as global at the start of every 
> function.
> i.e.
> 
> <?php  
>     $DEBUG = 2;
> 
>     function capture_talk(){
>        global $DEBUG; // This is the line I wish to be able to forget
>        if ($DEBUG) print "Debug is on<br>";
>        if ($DEBUG >=2) print "Debug is on level 2<br>";
> etc..
> 
> Thanks
> Tim
> _______________________________________________
> PLUG discussion list: plug at plug.linux.org.au
> http://mail.plug.linux.org.au/cgi-bin/mailman/listinfo/plug
> Committee e-mail: committee at plug.linux.org.au




More information about the plug mailing list