When we have something like:
if (null === ($bar = $foo->getBar())) {
}
Are we doing three things on this single line ?
Are we:
1) Declaring a variable.
2) Attribute that variable a value.
3) Check if that variable value is null.
?
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.
Yup, exactly like:
$barwill receive the value returned by$foo->getBar(), and then the expression tests whether that (the result of the assignment expression, which is the value that got assigned to$bar) is=== null. (And if this is the first use of$bar, then it’s creating a new variable.)