I'm trying to simplify this control block:
if (!isset($mobileNumberHF['IS_VALID']) && $mobileNumberHF['IS_VALID'] != 0) {
echo '<strong class="text-warning">Sin validar</strong>';
} else if ($mobileNumberHF['IS_VALID'] == 0) {
echo '<strong class="text-danger">Inválido</strong>';
} else {
echo '<strong class="text-success">Validado</strong>';
}
Like this:
$isValidMobileNum = $mobileNumHF['IS_VALID'];
$mobileNumStatusLabel = ($isValidMobileNum == 1) ? 'Valid' : (!isset($isValidMobileNum)) ? 'Hasn't been validated' : 'Invalid';
The test scenarios are when $isValidMobileNum equals NULL, 0 or 1;
By now, the result varies in a way I'm still trying to understand. Sometimes the output is 'Valid', sometimes 'Invalid' and sometimes 'Hasn't been validated'
For example, for $isValidMobileNum = 1 I'm getting Invalid?
!isset($mobileNumberHF['IS_VALID']) && $mobileNumberHF['IS_VALID'] != 0? How can it be not set and have a value != 0?