ngreenwood6 Posted July 31, 2008 Share Posted July 31, 2008 I have the following code: if (!$variable) { do this } but i want something like this if (!$variable and !$variable and $variable > 1) { do this } Can someone please tell me how to make it test more than 1 variable? Link to comment Share on other sites More sharing options...
phpSensei Posted July 31, 2008 Share Posted July 31, 2008 <?php if ((!$variable)&&(!$variable)&&($variable > 1)) { do this } ?> Link to comment Share on other sites More sharing options...
papaface Posted July 31, 2008 Share Posted July 31, 2008 if ($variable = "Hello" && strlen($variable) > 1 && $variable != NULL) { do this } Link to comment Share on other sites More sharing options...
phpSensei Posted July 31, 2008 Share Posted July 31, 2008 if ($variable = "Hello" && strlen($variable) > 1 && $variable != NULL) { do this } bad coding, it needs to be '==' <?php $variable = 'Helfwfwqlo'; if ($variable = "Hello") { echo 1; } ?> that would echo 1 Link to comment Share on other sites More sharing options...
papaface Posted July 31, 2008 Share Posted July 31, 2008 if ($variable = "Hello" && strlen($variable) > 1 && $variable != NULL) { do this } bad coding, it needs to be '==' <?php $variable = 'Helfwfwqlo'; if ($variable = "Hello") { echo 1; } ?> that would echo 1 Not bad coding, just a mistake..... Bad coding is your <?php if ((!$variable)&&(!$variable)&&($variable > 1)) { do this } ?> As you have two conditions which are exactly the same. Link to comment Share on other sites More sharing options...
ngreenwood6 Posted July 31, 2008 Author Share Posted July 31, 2008 actually i have three different variables. I am trying to submit a form, but if they dont submit a email, firstname and lastname it wont go through Link to comment Share on other sites More sharing options...
obsidian Posted July 31, 2008 Share Posted July 31, 2008 Please keep personal attacks and any other senseless mud slinging out of the forums. There is no need for a tirade of critiqued code. That is what this forums is intended for. If you feel someone has mistreated you or abused the forums in some way, contact a moderator or administrator. **LOCKED** @ngreenwood6 - I apologize if the comments have forced me to lock this code prematurely. If you have further questions, please feel free to start another topic. Link to comment Share on other sites More sharing options...
Recommended Posts