Jump to content

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)

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.