Re: RE : [PHP-DEV] variable_exists() patch

From: Date: Wed, 20 Aug 2003 17:40:46 +0000
Subject: Re: RE : [PHP-DEV] variable_exists() patch
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-4111@lists.php.net to get a copy of this message
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 constants, but it won't mess with your variables if you encapsulate properly. Additionally, for variables: isset() suffices. If a variable is null, you can treat it as nonexistant. ---This is where you are wrong. One cannot treat a variable with a null as its value as
nonexistent. PHP itself doesn't even do that. <?php $foo = null; echo $foo; echo $nonexistent; ?> You will get PHP warnings on line 4 that $nonexistent doesn't exist, but NO warnings on line 3 about $foo. PHP doesn't treat them the same, so how are we. PHP itself isn't consistent, and why we all asked for variable_exists() to begin with. It helps clear up the inconsistency w/ isset() and PHP's handling of echo $foo; vs. echo $nonexistent. Walt

« previous php.internals (#4111) next »