Jiblob Posted February 14, 2007 Share Posted February 14, 2007 Hello, I wish to have the verification for my form in in the following form: - if (!$blah) { echo "ERROR!"; } else { echo "FINE!"; } ... everything was fine, but then i put used a strlen(); to test that a string is NOT more than or equal to 25, so take this code for instance: - <?php $var = "111111111111111111111111111111"; // 30 Chars Long Var if ((!strlen($var) <= 25)) { echo "Error"; } else { echo "Fine"; } ?> For some reason it tells me that there is an error at any length, when it's only supposed say there is an error if it is over 25 characters in length. Help ??? - Luke Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted February 14, 2007 Share Posted February 14, 2007 Your logic is a bit reversed. What you want is if( strlen($var)>=25 ) Your code above would be correct if the ! was moved: if( !(strlen($var) <= 25) ) Quote Link to comment Share on other sites More sharing options...
Jiblob Posted February 15, 2007 Author Share Posted February 15, 2007 Thanks for the help ShogunWarrior, however, I did not fix it like this. I was stupid really, there was no need for the !strlen "NOT MORE THAN OR EQUAL TO 25", because this is just equivalent to strlen "MORE THAN 25". Silly me! haha Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.