Im trying to test a validation using an if statement.
if (($red == "1") && ($blue = "1") ) { $green = "hello"; }
Before this statement runs $blue = 0.
After i run this… $blue changes to 1.
Any ideas why?
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.
You are using
=in place of==:As a result (assuming the left side of
&&returns true)$bluegets assigned"1".It’s one of the most common programming mistakes!! As a way to prevent it from happening programmers put the constant on the left hand side of the the
==as:so that if by mistake you end up writing
=in place of==:you get a syntax error as you cannot assign to a constant.