ID: 26054
User updated by: sascha dot wildgrube at steganos dot com
Reported By: sascha dot wildgrube at steganos dot com
Status: Open
Bug Type: *Programming Data Structures
Operating System: all
PHP Version: 4.3.2
New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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:

P error: p error in /somefile.php4 on line 3: unreferenced
object "$nVale1"

Actual result:
--------------
20


------------------------------------------------------------------------


--
Edit this bug report at [url]http://bugs.php.net/?id=26054&edit=1[/url]