Zend Studio reports warning: Assignment in condition. Is this so bad?

后端 未结 8 1632
轻奢々
轻奢々 2020-12-11 02:47

I have recently started using Zend Studio which has reported as warning the following type of code:

$q = query(\"select * from some_table where some_conditio         


        
8条回答
  •  遥遥无期
    2020-12-11 03:31

    Actually, I guess your question has already been answered, somewhat. But to address your actual problem, I think this might help.

    //i dont know what is returned if there are no more records to fetch...
    //but lets assume it is a boolean value
    while (($f = fetch($q))!= false)
    {
        $this->doSomethingVeryImportantThatMakesYourBossHappy($f);
    }
    

    That should do the trick and the "Assignment in condition"-message should disappear.

    As a sidenote: use the equals operator the same way as when you negate stuff. You also use the equals sign with other operators like

    if ($falseness != false){$trueness = true}
    

    and not

    if ($falseness ! false){$trueness = false}
    

    That helps me to always remember how to compare values and not assign values to them.

提交回复
热议问题