You will get PHP warnings on line 4 that $nonexistent doesn't exist, but
NO warnings on line 3 about $foo.
Stop repeating obvious stuff please, everyone on the list knows this.
PHP doesn't treat them the same, so how are we.
PHP itself isn't consistent, and
why we all asked for var
So I ask this:
get_declared_classes, class_exists
get_defined_functions, function_exist
get_defined_constants, defined
get_defined_vars, ???
classes, functions, constants are available everywhere, not just in the
current function. Including a foreign library adds classes, functions
and con
On Tue, Aug 19, 2003 at 05:32:41PM -0500, Shaun Thomas wrote:
> > > 2.) variable_exists can not be written in PHP.
> >
> > And it is not necessary, because get_defined_vars() exists.
>
> Which is just plain gross, but let's continue on...
How many local variables do you have? That array shouldn'
On Wed, 20 Aug 2003, Stefan Walk wrote:
> Won't work.
> [EMAIL PROTECTED]:~$ php -r 'var_dump(isset($var) || is_null($var));'
>
> Notice: Undefined variable: var in Command line code on line 1
> bool(true)
Ah yes. I was writing from the perspective of having set a value to
null beforehand. M
On Tue, Aug 19, 2003 at 04:38:03PM -0500, Shaun Thomas wrote:
> On Tue, 19 Aug 2003, fabrice wrote:
>
> > Empty($var) ? DoSomethingIfNotSetOrNull() : DoOther();
>
> That won't work. empty() will return true if the variable is set to a
> literal zero, false, blank, or null. So for your use, it's
On Tue, 19 Aug 2003, fabrice wrote:
> Empty($var) ? DoSomethingIfNotSetOrNull() : DoOther();
That won't work. empty() will return true if the variable is set to a
literal zero, false, blank, or null. So for your use, it's actually
worse than isset assuming your data can have zeros or blank val
You may consider to use "empty" function that check if isset and not NULL
And also "!empty" inverse function.
Empty($var) ? DoSomethingIfNotSetOrNull() : DoOther();
Also it is true, I use a personnal function to check var ...
Something like that
Function variable_exists( $var )
{
$retur