You are here: Re: isset(), undefined variables, and null « PHP Programming Language « IT news, forums, messages
Re: isset(), undefined variables, and null

Posted by arundelo on 07/01/07 23:24

gosha bine wrote:

> You could also inspect the symbol table directly via
> get_defined_vars

Ah yes! (This also occurred to me after my original post.)

$Vars = get_defined_vars();
if (isset($Foo) || array_key_exists('Foo', $Vars)) {
// Safe to evaluate $Foo:
var_dump($Foo);
} else {
echo "Not safe to evaluate \$Foo.\n";
}

> but that's ugly.

Indeed, but not quite as bad as my other solution.

Andrew Hutchings wrote:

> You could use is_null().

Nope, is_null() always tries to evaluate its argument, so an
E_NOTICE might be emitted.

--
Aaron
http://arundelo.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

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