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 Link to comment https://forums.phpfreaks.com/topic/140387-solved-and-or-in-php/ 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 Link to comment https://forums.phpfreaks.com/topic/140387-solved-and-or-in-php/#findComment-734677 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 || Link to comment https://forums.phpfreaks.com/topic/140387-solved-and-or-in-php/#findComment-734844 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. Link to comment https://forums.phpfreaks.com/topic/140387-solved-and-or-in-php/#findComment-734849 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. Link to comment https://forums.phpfreaks.com/topic/140387-solved-and-or-in-php/#findComment-735578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.