why are assignments in conditions bad?

后端 未结 6 443
长发绾君心
长发绾君心 2020-12-16 09:45

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         


        
6条回答
  •  时光取名叫无心
    2020-12-16 10:27

    It's probably trying to help you avoid the dreaded typo:

    if(a = b)
       //logic error
    

    Although I would expect an enviroment smart enough to warn you about that, to also be smart enough to have "oh, don't worry about that case" conditions.

提交回复
热议问题