The biggest problem with assignement in condition is when you have more than one condition:
if ($foo = foo() && bar()) Will not work as expected (given you wanted the result of foo() in $foo). you'd rather write: if (($foo = foo()) && bar()) Also, to avoid confusion with ==, you can invert the terms of the condition: if (bar() == 'bar') since forgetting a = will raise a fatal error also, +1 to what David said On Wed, Dec 16, 2009 at 10:24 PM, David at Artefactual < [email protected]> wrote: > I think this code example is a bit problematic because the conditional > statement is not actually returning a boolean value, it's relying on > php's loose comparisons to evaluate the truth of the conditional. I > think it's clearer to explicitly indicate your true / false condition: > > if (null !== ($results = $this->getResults())) > { > > Just my two bits. > > David Juhasz > > -- > > You received this message because you are subscribed to the Google Groups > "symfony developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<symfony-devs%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/symfony-devs?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en.
