You are here: Re: [PHP] Type of form element « PHP « IT news, forums, messages
Re: [PHP] Type of form element

Posted by Ben Ramsey on 10/06/48 11:31

On 11/8/05 11:38 PM, Richard Lynch wrote:
> If you want to stuff NULL into something, and then use is_null() that
> makes sense.
>
> If you want to stuff NULL in there, and then use isset(), I'm not
> quite sure why you'd put NULL in there in the first place, but I don't
> rightly know what I'd expect isset() to return. Same for $a or
> $myarray['a']

I know this is off-topic for this thread, but just as I see isset()
misused (as in this case), I often see empty() misused. For example,
when using empty(), the following all return TRUE:

$a = 0;
$b = NULL;
$c = FALSE;
$d = "0";

var_dump(empty($a));
var_dump(empty($b));
var_dump(empty($c));
var_dump(empty($d));

But, hey, is the value of the variable really empty (especially for $a
and $d)?

Likewise, if you're encountering a NULL value in a variable and you're
checking it with isset(), then you need to consider why you're even
getting a NULL value? You should filter your variables before you use
them--even variables coming from $_SERVER.

Remember, $_SERVER variables can be overwritten:

$_SERVER['SERVER_NAME'] = 'Howdy Doody';
echo $_SERVER['SERVER_NAME'];

So, make sure they're what you expect them to be.

--
Ben Ramsey
http://benramsey.com/

 

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

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