can anybody tell me the difference of using ‘===’ as
if (null === $this->getName())
and
if ($this->getName() === null )
if $this->getName is already defined.
thanks in advance
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.
There is no difference between the two conditionals, however, it is a common practice to place the value you are checking first, so you don’t accidentally turn a conditional check into an assignment operation:
You can also use the is_null PHP function for testing if variables are null.