Can I use the OR argument in this way in PHP? Meaning if $x is null assign $y to $var.
$var = $x || $y
Simple question, cheers!
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.
No. PHP’s boolean operators evaluate to
trueorfalse, not the value of the operands as in Javascript. So you’ll have to write something like this:Since 5.3, you can write this though, which basically has the same effect as Javascript’s
||:That requires that
$xexists though, otherwise you should check withissetfirst.