#26054 [Opn->Bgs]: using unreferenced variables does not produce errors
| From: | alan_k@php.net | Date: | Fri, 31 Oct 2003 12:54:55 +0000 |
| Subject: | #26054 [Opn->Bgs]: using unreferenced variables does not produce errors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-49752@lists.php.net to get a copy of this message | ||
ID: 26054
Updated by: alan_k@php.net
Reported By: sascha dot wildgrube at steganos dot com
-Status: Open
+Status: Bogus
Bug Type: *Programming Data Structures
Operating System: all
PHP Version: 4.3.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
try error_reporting(E_ALL);
Previous Comments:
------------------------------------------------------------------------
[2003-10-31 07:37:12] sascha dot wildgrube at steganos dot com
An even better solution would be the need to initialize variables like
that "var $nValue;". This way even typos in in lvalues would not do
any harm.
We once observed how much percent of the time was consumed by this bug.
We found out that 30% of the time when working on php code could be
saved if php had strict variable usage.
------------------------------------------------------------------------
[2003-10-31 07:26:30] sascha dot wildgrube at steganos dot com
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 this bug report at http://bugs.php.net/?id=26054&edit=1