PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I can't remember if this was in PHP or Javascript but I know that if I use the '=' operator, rather then '==', in a conditional statement that it wouldn't just check for the condition, it would actually set thart to thucker.
Last edited by JellyFish on Fri Aug 17, 2007 1:40 pm, edited 1 time in total.
Yes it will move the pointer if there is another record and will return false if you are at the end. So in the else you should prev() and do the other tasks.
But, does the php language have a way of preventing actual execution of the statement when it's in a conditional statement? Kind of a stupid question, because if there was one that you knew about you probably would have used it in the examples above.
EDIT:
Also, @jCart: I know that the function advances the array pointer. My question was, would it advance if it was in a condition. My question wasn't about the function so much, as it was more about the php language in general.
PS: Note the 'was' in "My question was, would it ad...", just in case someone is thinking that I'm still asking that question(which I'm not).
Last edited by JellyFish on Fri Aug 17, 2007 1:47 pm, edited 1 time in total.
But, does the php language have a way of preventing actual execution of the statement when it's in a conditional statement? Kind of a stupid question, because if there was one that you knew about you probably would have used it in the examples above.
That is an odd question. The answer is no.
Your best bet is probably following feyd's suggestion.
The answer is no. Every condition is executed, this is why should not be used for($i=0;$i<count($array);$i++) /count() is executed on every iteration/, while($row = mysql_fetch_assoc(mysql_query('SELECT * FROM `table`')) /query is executed on every iteration and causes infinite loop/.
Example: if(isset($_GET['foo'])) executes the function isset() in the condition.
miro_igov wrote:The answer is no. Every condition is executed, this is why should not be used for($i=0;$i<count($array);$i++) /count() is executed on every iteration/, while($row = mysql_fetch_assoc(mysql_query('SELECT * FROM `table`')) /query is executed on every iteration and causes infinite loop/.
Example: if(isset($_GET['foo'])) executes the function isset() in the condition.
Yeah, that makes sense. I don't think it would be a good idea not to have the statements executed, just that it was possible with an function or operator of some kind. Kinda like how void() prevents the statement from returning something.