web_master Posted January 11, 2009 Share Posted January 11, 2009 Hi, what is the synthax for "AND" and "OR" in PHP? example must work only if all the POST's are true: if($_POST['text_1'] AND $_POST['text_2'] AND $_POST['text_3']) { $view = "1"; } must work if one of Post's is true: if($_POST['text_1'] OR $_POST['text_2'] OR $_POST['text_3']) { $view = "1"; } So what is the right sintax in PHP for "AND" and "OR"? thnx Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 http://www.php.net/manual/en/language.operators.logical.php Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted January 11, 2009 Share Posted January 11, 2009 Hi, what is the synthax for "AND" and "OR" in PHP? example must work only if all the POST's are true: if($_POST['text_1'] AND $_POST['text_2'] AND $_POST['text_3']) { $view = "1"; } must work if one of Post's is true: if($_POST['text_1'] OR $_POST['text_2'] OR $_POST['text_3']) { $view = "1"; } So what is the right sintax in PHP for "AND" and "OR"? thnx AND is &&, and OR is || Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 Also AND is AND and OR is OR... They work a bit different though (have different priorities). See the manual link for examples. Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted January 12, 2009 Share Posted January 12, 2009 Also AND is AND and OR is OR... They work a bit different though (have different priorities). See the manual link for examples. Hey, that's cool! I've read a lot of books on php, and not one of them showed the use of AND and OR. I always thought that && and || were the only choices for AND and OR. 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.