code_junkie

why are assignments in conditions bad?

Nov 12th, 2011
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. if (($row = $db->get_row($sql))) {
  2. return $row->folder;
  3. } else {
  4. return FALSE;
  5. }
  6.  
  7. if (a = 1) { .. }
  8.  
  9. if (a == 1) { .. }
  10.  
  11. if (1 == a) { .. }
  12.  
  13. if (a = 1) { .. }
  14.  
  15. if(a = b)
  16. //logic error
  17.  
  18. if ( a=func(x) && b=func(y) )
  19. {
  20. // do this
  21. }
  22.  
  23. if ( a==func(x) && b==func(y) ) ...
  24.  
  25. $counter = 0;
  26. while( $getWhateverDataObj = mysql_fetch_object( $sqlResult )) {
  27. $getWhateverObj->firstName[$counter] = $getWhateverDataObj->firstName;
  28. $getWhateverObj->lastName[$counter] = $getWhateverDataObj->lastName;
  29. $counter++;
  30. }
  31.  
  32. $next = mysql_fetch_assoc($result)
  33. do{
  34. ...
  35. ...
  36. ...
  37.  
  38. $next = mysql_fetch_assoc($result) or break;
  39. }while ($next)
Add Comment
Please, Sign In to add comment