shane18 Posted February 8, 2010 Share Posted February 8, 2010 Is the only time you can use a assignment operator in a condition, is when your getting data out of a database using a while loop. For Example: while($ROW = $RESULT->fetch_object()){ //Code } Link to comment https://forums.phpfreaks.com/topic/191297-assignment-operator/ Share on other sites More sharing options...
JAY6390 Posted February 8, 2010 Share Posted February 8, 2010 It's not the only time no, but there's few other times you'll need to use it. What that while does is evaluate that the row data is assigned to $row. If it isn't (when there's no data) it assigns FALSE to the value, and the while does not run Link to comment https://forums.phpfreaks.com/topic/191297-assignment-operator/#findComment-1008602 Share on other sites More sharing options...
shane18 Posted February 8, 2010 Author Share Posted February 8, 2010 ok well why does if statements and while loops behave like this.... while($ROW = $RESULT->fetch_object() && GROUP_SHOW == 1){ //Code } -don't work.... while(GROUP_SHOW == 1 && $ROW = $RESULT->fetch_object()){ //Code } -works.... why does it only work when its the only one or the last one in the if statement / while loop? can someone explain how this works? Link to comment https://forums.phpfreaks.com/topic/191297-assignment-operator/#findComment-1008603 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.