vincent30000 Posted April 8, 2010 Share Posted April 8, 2010 hi guys, I am kind of new to php and also to programing. I would like to get your inputs on the following conditional statement. if (is_array($_POST) && count($_POST) > 1) now the first condition in this statement gives a true... that is understandable but the second condition gives the result of the number of array elements passed to the post via the form. In this case its 2. Then how is this if statement is always true. I mean if we take it some thing like this if (true && 2 >1) hows this statement evaluated ? I would really appreciate if some one can explain the same.... Thanks in advacne...... Quote Link to comment Share on other sites More sharing options...
tmallen Posted April 8, 2010 Share Posted April 8, 2010 if (true && 2 >1) The (bool) value of each operand, that is, the value of each expression (left and right-hand) when cast as boolean, evaluate to true, so the full "&&" statement evaluates to true. http://www.php.net/manual/en/language.operators.logical.php http://www.php.net/manual/en/language.operators.precedence.php Quote Link to comment Share on other sites More sharing options...
vincent30000 Posted April 8, 2010 Author Share Posted April 8, 2010 thanks tmallen.... I was trying to figure that out and realized that the > operator will be evaluated first according to the precedence rules, and then the && operator will get evaluated.... and since 2>1 is true so...the two conditions come out to be true and hence the result... thanks once again... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.