if (strlen($title) && strlen($message) > 3)
This returns true if $title is over 3 chars, I only want it to return true if BOTH is.
Whats the correct way? Tried a bunch. FNYS.
Help please.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if ((strlen($title) > 3) && (strlen($message) > 3))
I do see what you’re shooting for, but it’s not often supported. In general, each chunk of the “if” test is self-standing — I like to add extra parentheses, just to make things clearer to scan.
So your original test boiled down to “if(strlen($title))” and “if(strlen($message) > 3)”.