Re: Is there any way that PHP will issue a warning when using undeclared vars?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2 Jan 2005 16:23:34 -0800, Dan Eloff <dan.eloff@xxxxxxxxx> wrote:
> My single biggest beef with PHP is the fact that it silently fails
> when I use a variable that has never been declared. Like if($sumbit)
> will always be false because the variable was really named $submit. My
> only clue that this is happening is whe the program fails to work as
> intended and I waste lots of time trying to find out why the block
> never executes.
> 
> Or if you forget to use $this->var and you just use $var. I just had
> that happen to me too. Wasted another 30 min.
> 
> Is there any way at all to control this? I went into my PHP.ini file,
> but my errors are set to E_ALL & E_STRICT which seems to be the
> highest level I can set.
> 
> If not I think we should seriously push for E_STRICT warnings if a
> variable is used without every being assigned to.

I usally do something like this when I start a project, so I can
easily turn it back off later when my code goes production:
 
if( $debug )
{
    error_reporting( E_ALL );
    ini_set( 'display_errors', 1 );
    ini_set( 'log_errors', 1 );
}
else
{
    error_reporting( E_ERROR | E_WARNING | E_PARSE );
    ini_set( 'display_errors', 0 );
}


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux