RE: [PHP] == vs = should generate a warning or error -- was: Why won't this work?
| From: | Daevid Vincent | Date: | Sat, 20 Jul 2002 11:34:10 +0000 |
| Subject: | RE: [PHP] == vs = should generate a warning or error -- was: Why won't this work? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108650@lists.php.net to get a copy of this message | ||
> That would suck since many many PHP programs use stuff like:
>
> while($row=mysql_fetch_row($result)) { ... }
>
> There is absolutely nothing wrong with doing an assignment in
> a conditional and if it generated a warning it would drive a
> lot of people crazy.
First off, I have to LMAO at "that would suck".
So unexpected but humorus.
But seriously, this is why I suggest it be a config file option. Not a
new way of doing things, to break old code. But something toggle-able.
Or, I'm sure the PHP parser could be made smarter to look for common
'assigments' that are supposed to be 'conditions'.
For example I seriously doubt that NOBODY EVER means to do
if ($x = 5)
{
}
That CLEARLY is supposed to be using a == and not =
And I'm sure there are other such obvious cases that the parser could
check for somehow.
Just a suggestion. Thass all.