I have this variable: $logged_in_person_rsvp - its value = -1

Then I run this code:

$yes_checked = ($logged_in_person_rsvp===1) ? "checked" : "";
$maybe_checked = ($logged_in_person_rsvp===-1) ? "checked" : "";
$no_checked = ($logged_in_person_rsvp===0) ? "checked" : "";

echo '<p>logged_in_person_rsvp: '.$maybe_checked.'</p>';

And I get output as nothing. But I was expecting the output to be -1

Anyone understand why? This is weird syntax I inherited :)

Accepted Answer

Try using two equals signs like "==" instead of 3 and see if that makes a difference. If so, your strict comparison is probably messing up your intended result.

Written by ldg
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki