Dale_G Posted May 4, 2008 Share Posted May 4, 2008 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? Link to comment https://forums.phpfreaks.com/topic/104097-solved-double-pipe-and-double-and-ampamp-difference-question/ Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 logically speaking: || is OR && is AND Link to comment https://forums.phpfreaks.com/topic/104097-solved-double-pipe-and-double-and-ampamp-difference-question/#findComment-532897 Share on other sites More sharing options...
Dale_G Posted May 4, 2008 Author Share Posted May 4, 2008 Oh okay..wow how simple. 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? Link to comment https://forums.phpfreaks.com/topic/104097-solved-double-pipe-and-double-and-ampamp-difference-question/#findComment-532903 Share on other sites More sharing options...
shank888 Posted May 4, 2008 Share Posted May 4, 2008 Oh okay..wow how simple. 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. Link to comment https://forums.phpfreaks.com/topic/104097-solved-double-pipe-and-double-and-ampamp-difference-question/#findComment-532906 Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 looks good to me! Link to comment https://forums.phpfreaks.com/topic/104097-solved-double-pipe-and-double-and-ampamp-difference-question/#findComment-532907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.