#26054 [NEW]: using unreferenced variables does not produce errors
| From: | sascha dot wildgrube at steganos dot com | Date: | Fri, 31 Oct 2003 12:26:30 +0000 |
| Subject: | #26054 [NEW]: using unreferenced variables does not produce errors | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-49748@lists.php.net to get a copy of this message | ||
From: sascha dot wildgrube at steganos dot com
Operating system: all
PHP version: 4.3.2
PHP Bug Type: *Programming Data Structures
Bug description: using unreferenced variables does not produce errors
Description:
------------
Any variable identifier can be used in a statement - even if it hasn't
been referenced before - without producing an error.
Most of the time when debuggong php code is spent for searching typos in
variable names.
I consider it a bug that php does not produce and display error if it
encounters an unreferenced variable in a statement.
A solution could be a "strict" statement. That tells php to throw errors
in that case to stay backward compatible.
An even better solution would be the need to
Reproduce code:
---------------
$nValue1 = 10;
$nValue2 = 20;
print($nVale1 + $nValue2);
Expected result:
----------------
Expected:
30
No, it is:
20
Why, because of the typo in line 3. What I want to happen in that case is
this:
Parse error: parse error in /somefile.php4 on line 3: unreferenced object
"$nVale1"
Actual result:
--------------
20
--
Edit bug report at http://bugs.php.net/?id=26054&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26054&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26054&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26054&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26054&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26054&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=26054&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26054&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26054&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26054&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26054&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26054&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26054&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26054&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26054&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26054&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26054&r=float