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/03/07 04:13

Norm:

> No... !isset($Foo) determines if $Foo is ok to evaluate.

When I say "safe to evaluate", I mean it in exactly the
sense of the the first sentence of the original post:

> Is there a way to tell whether accessing a variable will
> result in an "Undefined variable" E_NOTICE?

Norm:

> $dump = array_key_exists('Foo',$GLOBALS) ? var_dump($Foo)
> : 'Not safe to evaluate.';
>
> should be what you're looking for, No?

Doesn't work if $Foo is local. The get_defined_vars()
solution upthread does exactly what I what I was seeking,
despite its kluginess. So does your error_get_last() idea
mentioned downthread (this is a variation on my solutions
from the original post).

> I'd like to see how your using this...

Oh, I'm not using it; I just realized that isset()'s
behavior is, IMHO, broken, and I was curious if there was
something that did what I thought isset() should do. (In
the actual situation that inspired my curiosity, I wanted to
know whether it was safe to evaluate $Foo['Bar'], but
array_key_exists('Bar', $Foo) works fine for that.)

Thanks,

--
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

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