You are here: Zero and NULL « PHP SQL « IT news, forums, messages
Zero and NULL

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация