Re: PHP 4.0 Bug #6190: Compile message for undeclared variables
| From: | Lars Torben Wilson | Date: | Wed, 16 Aug 2000 01:23:41 +0000 |
| Subject: | Re: PHP 4.0 Bug #6190: Compile message for undeclared variables | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-29085@lists.php.net to get a copy of this message | ||
rabbott@CalStateLA.edu writes:
> From: rabbott@CalStateLA.edu
> 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@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+