Assignment in conditional operator
Posted
by DuoSRX
on Stack Overflow
See other posts from Stack Overflow
or by DuoSRX
Published on 2010-05-14T14:34:29Z
Indexed on
2010/05/14
14:44 UTC
Read the original article
Hit count: 175
php
|best-practices
I've seen a lot this kind of code recently :
if ($foo = $bar->getFoo())
{
baz($foo);
}
Is this considered good or bad practice ?
For example, Netbeans IDE give a notice if you use this kind of code :
Possible accidental assignment, assignments in conditions should be avoided
What do you think ?
© Stack Overflow or respective owner