I found this line of code and I’m trying to comprehend what it’s doing. The part I’m not familiar with is the question mark and the colon. What are these characters used for?
$string = $array[1] . ($array[0] === 47 ? '' : ' word');
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.
That’s a ternary operator; basically a short-hand conditional.
It’s the same as:
See this section in the PHP manual (the “Ternary Operator” section).