You are here: Re: undefined array index question « PHP Programming Language « IT news, forums, messages
Re: undefined array index question

Posted by Bent Stigsen on 09/17/05 23:57

Dikkie Dik wrote:
[snip]
> The non-existing variable is evaluated as NULL with a warning, not a
> fatal error. NULL gets cast to an empty string, which is "glued" between
> the 'M' strings. If you don't want the warning, you can temporarily
> switch it off by putting a '@' character in front of the expression or
> the command, like
> @$result=mArray['NonExistingKey'];
> echo 'M' . $result . 'M';
>
> You can use this feature to check if variables exists in a quick-and
> dirty way:
> @$strUrlParameter=$_GET['Command'];
> if(is_null($strUrlParameter))
> ...
[snip]

"isset" can also be used for this, which will suppress warning for
non-existent index. However "isset", or the code ove, will not tell
the difference between, an existing index assigned a NULL-value, and a
non-existing index.
That is probably also the point with accepting a non-existing index as
non-fatal. That is, why enforce a verification of an index, when
validation of its value is just as important. But as it just might be
a mistake, a warning is in order.

/Bent

 

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

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