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

Posted by gosha bine on 06/30/07 10:38

arundelo@hotmail.com wrote:
> Is there a way to tell whether accessing a variable will
> result in an "Undefined variable" E_NOTICE? isset() almost
> does this, but it also returns false if a variable is set to
> null:
>
> $SetNonNull = 0;
> $SetNull = null;
> var_dump(isset($SetNonNull)); // bool(true)
> $Junk = $SetNonNull; // No error, as predicted by isset().
> var_dump(isset($NotSet)); // bool(false)
> $Junk = $NotSet; // Raises an E_NOTICE, as predicted by isset().
> var_dump(isset($SetNull)); // bool(false)
> $Junk = $SetNull; // No error -- how to predict?
>
> I realize I could do this by e.g., doing @$Var and checking
> afterwards using $php_errormsg or a custom error handler;
> I'm hoping for something less klugey.
>
> Thanks,
>
> --
> Aaron
> http://arundelo.com/
>

I'm afraid you're out of luck with it. You could also inspect the symbol
table directly via get_defined_vars, but that's ugly.

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

 

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

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