What is this PHP code means ?
is_array($data) OR $data = (array) $data
I see this code on PyroCMS
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.
ORis a short-circuit operator. If the left side istrue, the right side will not be evaluated. It basically says “if$datais not an array, cast it to an array”.Note that this is rather redundant and could be abbreviated to:
This has the same effect. If it already is an array, casting to an array will do nothing, otherwise it will cast to an array.