Warning message when missing a =

[email protected] ("Andrea R.") Thu, 23 May 2002 11:38:53 +0200
Newsgroups php.lang
Message-ID <[email protected]>
Hi,

I saw often this typical user error while coding with php:

if ( $i = 55 ) // correct have to be if ( $i == 55 )
etc

There is a = missing.
This could happen and I encountered that missing me too.
Some people could suggest to use something like:

if ( 55 == $i )

so in the case of a = missing a warning is generated by php parser.

My ANSI C compiler ( for microcontroller ) warns me with "Warning, possible
bug on line..." when I type something like:
if ( i = 5 )

What I suggest is to have a warning message from PHP parser when the "right
operand" is a constant.
So
if ( $i = 5 )
if ( $i = "ciao" )
could give a warning

while

if ( $row = mysql_fetch_array() )
will not give an error.

I think that it will help a lot to debug complex applications.
I have no idea if it can have some sense what I said but I wanted to let you
know.

Regards
-- Andrea from Italy