Re: variable_exists() patch
| From: | walt boring | Date: | Thu, 14 Aug 2003 19:00:26 +0000 |
| Subject: | Re: variable_exists() patch | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-3949@lists.php.net to get a copy of this message | ||
Stefan Walk wrote:
On Thu, Aug 14, 2003 at 11:15:51AM -0700, walt boring wrote:So if for example a var isn't set for whatever reason, then trying to access the variable will throw a php Notice. variable_exists() would prevent that, as does isset(). isset() would work for my example below, but it still is a 'broken' function in my opinion. if ($var) { // <-- you'll get a php notice on this line switch ($var) { ... } } versus doing if (variable_exists($var)) { //no php notices here switch($var) { ... } }I for one would like to see something like variable_exists(), as I am very annoyed with the logic of isset() returning false if the variable exists and has a value of null.[snip]I for one would much rather do if ( variable_exists($var) ) {} versus if (isset($var) || is_null($var)) {}When do you need to do that? I can't think of many situations where it would be neccessary to check if a variable really exists. It can happen quite easily. I always develop with full warnings/errors on.