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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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