Warning message when missing a =
| From: | Andrea R. | Date: | Thu, 23 May 2002 09:38:53 +0000 |
| Subject: | Warning message when missing a = | ||
| Groups: | php.lang | ||
| Request: | Send a blank email to php-lang+get-309@lists.php.net to get a copy of this message | ||
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