Jump to content

Stuck on a multiple condition statement


john2020

Recommended Posts

Folks,

 

I am trying to learn PHP and  I have spent the morning trying to sort out something seemingly simple  but it is not working for me.

 

I want to write a statement which says: if session variable "one" is empty or if session variable "two" is not equal to "svValue" then do this:

 

if ((empty ($_SESSION["One"])) || if ($_SESSION["Two"] != "svValue ) {

do this;

}

 

Could you point out the mistake(s) in my syntax?

 

Thanks!

John

Link to comment
https://forums.phpfreaks.com/topic/224440-stuck-on-a-multiple-condition-statement/
Share on other sites

Thank you!  Just to clarify, shouldn't the double quotes be closed after svValue? In my original question I made a typo and didn't close the quotes.

 

So would this be correct (just closed the quotes)?

 

if( empty($_SESSION["One"]) || ($_SESSION["Two"] != "svValue" ) ) {
do this;
}

Thank you for your help.  You got the typo form my original.

 

Just an FYI, there are a few more values that will qualify as 'empty'.  From the manual (empty):

 

The following things are considered to be empty:

 

    * "" (an empty string)

    * 0 (0 as an integer)

    * "0" (0 as a string)

    * NULL

    * FALSE

    * array() (an empty array)

    * var $var; (a variable declared, but without a value in a class)

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.