Jump to content

[SOLVED] Double Pipe (||) and Double And (&&) Difference Question!


Dale_G

Recommended Posts

Right, I have a question.

 

I've seen the use of the double pipe character || and the double and character && in PHP alot.

 

Now, this probably isn't the case, but I often see them being interchanged quite frequently. I'm sure theres a difference between the two, can someone help explain that to me?

 

Basically, what's the difference between '||' and '&&' and how would you make use of them?

Oh okay..wow how simple. :D

 

So basically..

 

In an if statement using || or &&, if you use || such as

 

if ( 1 == 1 || 2 == 2 )

    {

        DO THIS

    }

 

it means that ONE of them has to be true, but if you use && it means both of them has to be true.

 

Am I right?

Oh okay..wow how simple. :D

 

So basically..

 

In an if statement using || or &&, if you use || such as

 

if ( 1 == 1 || 2 == 2 )

    {

        DO THIS

    }

 

it means that ONE of them has to be true, but if you use && it means both of them has to be true.

 

Am I right?

 

to my knowledge you are correct.

Archived

This topic is now archived and is closed to further replies.

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