Re: [PHP] assigning NULL to a variable
William Lovaton wrote: El mar, 06-04-2004 a las 07:41, Marek Kilimajer escribió: Andy B wrote: how would you assign NULL to a variable if its original value is ? otherwise leave it with its value... if($var === '') $var = NULL; what about: if ($var == '') unset($var); No - NULL is not the same as unset() and the condition would evaluate to true even if $var === 0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] assigning NULL to a variable
Marek Kilimajer wrote: William Lovaton wrote: El mar, 06-04-2004 a las 07:41, Marek Kilimajer escribió: Andy B wrote: how would you assign NULL to a variable if its original value is ? otherwise leave it with its value... if($var === '') $var = NULL; what about: if ($var == '') unset($var); No - NULL is not the same as unset() and the condition would evaluate to true even if $var === 0 And if $var = false or null or '0' -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] assigning NULL to a variable
Andy B wrote: how would you assign NULL to a variable if its original value is ? otherwise leave it with its value... if($var === '') $var = NULL; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] assigning NULL to a variable
El mar, 06-04-2004 a las 07:41, Marek Kilimajer escribió: Andy B wrote: how would you assign NULL to a variable if its original value is ? otherwise leave it with its value... if($var === '') $var = NULL; what about: if ($var == '') unset($var); -William -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] assigning NULL to a variable
how would you assign NULL to a variable if its original value is ? otherwise leave it with its value... the form im working on has a date field called date on the form itself. that date will get turned into $_SESSION[add][date] on the next page... i want it so if the person filling out the form didnt leave a date (left date field blank) then it should be NULL so the mysql table will insert the current date... so far i have this code: if(empty($_SESSION['add']['date'])){ $_SESSION['add']['date']=NULL//or should it = FALSE?? } //if its already filled do nothing else to it is there a better way to do this than this way?