john2020 Posted January 14, 2011 Share Posted January 14, 2011 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 More sharing options...
Rifts Posted January 14, 2011 Share Posted January 14, 2011 if( empty($_SESSION["One"]) || ($_SESSION["Two"] != "svValue ) ) { do this; } not tested Link to comment https://forums.phpfreaks.com/topic/224440-stuck-on-a-multiple-condition-statement/#findComment-1159414 Share on other sites More sharing options...
john2020 Posted January 14, 2011 Author Share Posted January 14, 2011 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; } Link to comment https://forums.phpfreaks.com/topic/224440-stuck-on-a-multiple-condition-statement/#findComment-1159430 Share on other sites More sharing options...
Rifts Posted January 14, 2011 Share Posted January 14, 2011 yeah you are correct, my bad typo Link to comment https://forums.phpfreaks.com/topic/224440-stuck-on-a-multiple-condition-statement/#findComment-1159437 Share on other sites More sharing options...
john2020 Posted January 14, 2011 Author Share Posted January 14, 2011 Thank you for your help. You got the typo form my original. Link to comment https://forums.phpfreaks.com/topic/224440-stuck-on-a-multiple-condition-statement/#findComment-1159445 Share on other sites More sharing options...
Maq Posted January 14, 2011 Share Posted January 14, 2011 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) Link to comment https://forums.phpfreaks.com/topic/224440-stuck-on-a-multiple-condition-statement/#findComment-1159527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.