Jump to content

if and &&


vincent30000

Recommended Posts

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......

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.