Posted by Paul Lautman on 01/09/07 13:04
I have the following switch statement:
switch ($record->sub_page) {
case -1:
$this->page = 6;
$error_message = '<center>You appear to have already completed the
form.</center>';
break;
case 0:
$this->page = 5;
ff_query("UPDATE #__gateway_form_1 SET `sub_page`=-1 WHERE
userid=$my->id and `expiry_date` = '$expiry_date'");
break;
default:
do something else
}
The value of $record->sub_page can be NULL. If it is NULL, the case for 0
seems to fire. I really need the default action to happen when
$record->sub_page is NULL or a +ve value.
However if I do:
switch ($record->sub_page) {
case -1:
$this->page = 6;
break;
case NULL:
do something else;
break;
case 0:
$this->page = 5;
break;
default:
do something else;
}
then the switch manages to tell the difference between a NULL and a zero.
Is it correct that php treats NULL as 0?
Can anyone suggest a good fix?
TIA
Regards
Paul
Navigation:
[Reply to this message]
|