Re: [PHP-DEV] PHP 4.0 Bug #6190: Compile message for undeclared variables From: Lars Torben Wilson (torben <email protected>)
Date: 08/15/00

rabbott <email protected> writes:
> From: rabbott <email protected>
> Operating system: NT 4
> PHP version: 4.0.0
> PHP Bug Type: Feature/Change Request
> Bug description: Compile message for undeclared variables
>
> It would help a lot if the compiler would generate
> an error message when attempting to access a variable
> that was never used. That would sure help with
> misspellings and with variable names with the "$"
> left off.

Use error_reporting() to set a higher error reporting level. When you
attempt to access a variable which has not been defined, an error is
issued at the E_NOTICE level. For instance:

<?php
error_reporting(E_ALL);

$foo = $bar;
?>

This script produces the following output:

  Warning: Undefined variable: bar in
  /home/torben/public_html/phptest/test.html on line 4

This error level will also tell you when you've accidentally left off
the '$' (for those cases when it doesn't simply generate a parse
error):

<?php
error_reporting(E_ALL);

$foo = bar;
?>

This script produces:

  Warning: Use of undefined constant bar - assumed 'bar' in
  /home/torben/public_html/phptest/test.html on line 4

Hope this helps,

Torben

-- 
+----------------------------------------------------------------+
|Torben Wilson <torben <email protected>>                     Netmill iTech|
|http://www.coastnet.com/~torben            http://www.netmill.fi|
|Ph: 1 250 383-9735                             torben <email protected>|
+----------------------------------------------------------------+

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>