You are here: Re: How to emulate isset() ? (is it possible?) « PHP Programming Language « IT news, forums, messages
Re: How to emulate isset() ? (is it possible?)

Posted by Umberto Salsi on 05/29/07 20:48

"Giovanni R." <linfo2003@NOSPAMlibero.it> wrote:

> Here it is how it could be used:
>
> print wrapper($array['inexistent_index']);
>
> In this way, even if $array['inexistent_index'] isn't defined, I don't
> get a notice. The fact is that wrapper() adds that index to the array
> and sets $array['inexistent_index'] to NULL. :-(

This code will say you all about the existence of the $array and its
element 'inexistent_index', also if this element is NULL:

if( isset($array) ){
echo "the array exists\n";
if( array_key_exists('inexistent_index', $array) ){
echo "the element array[inexistent_index] exists\n";
if( $array['inexistent_index'] === NULL ){
echo "...and it is NULL\n";
} else {
echo "...and it is not NULL\n";
}
} else {
echo "the element array[inexistent_index] does not exist\n";
}
} else {
echo "the array does not exist\n";
}

Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

 

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

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