Jump to content

[SOLVED] Simple if...else question


wwedude

Recommended Posts

Hello,

How would I create a code where the if condition is multiple variables? For example:

 

if variable=3 AND anothervariable=5 then echo "something", elseif variable=3 AND anothervariable=2 then echo "somethingelse"

 

Of course that was just me rambling on, and not my attempt at a php code.

 

 

Thanks for any and all help!

Link to comment
https://forums.phpfreaks.com/topic/121284-solved-simple-ifelse-question/
Share on other sites

if( $var == 3 && $othervar == 5 ) {

  echo "something";

} elseif( $var == 3 && $othervar = 2 ) {

  echo "Something else";

}

 

Remember, you can also nest if statements:

if( $var == 3 ) {

  if( $othervar == 5 ) {

    echo "someting";

  } elseif( $othervar == 2 ) {

    echo "something else";

  }

}

alil more clear explaination..

 

for OR's

 

if($Variable=='This' OR $Variable=='This')
{
//DO THIS
}

//OR YOU CAN DO THIS

if($Variable=='This' || $Variable=='This')
{
//DO THIS
}

 

for and's

 

if($Variable=='This' AND $Variable=='This')
{
//DO THIS
}

//OR

if($Variable=='This' && $Variable=='This')
{
//DO THIS
}

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.