Jump to content

[SOLVED] AND, OR in PHP


web_master

Recommended Posts

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

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

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

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.