I am using NetBeans for PHP 6.5.
In my code I frequently use the following type of command:
if (($row = $db->get_row($sql))) { return $row->folder; } else { return FALSE; }
Netbeans tells me that I should not be using assignments in the IF statement.
Why ?
They are not bad, but they can lead to dangerous mistakes.
In c like languages, where an assignment is an expression, (to support for example a=b=c=1;) a common error is:
But you wanted to have
Some developers have learned to type
To create an error if one ‘=’ is forgotten. But I think that it does not improve the readability.
However modern compilers, give a warning if you write
which I think is a better solution. In that case you are forced to check if it was what you really meant.