Re: Re: "isset" or "array_key_exists"?

From: Date: Sat, 18 Feb 2006 17:39:44 +0000
Subject: Re: Re: "isset" or "array_key_exists"?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-230694@lists.php.net to get a copy of this message
Actually, it doesn't have much sense that it creates a variable (or index), though it had sense why wouldn't be so easily detected, so I printed the array after the loops and there's no new keys. I think that if that was the case, it was definitely a bug that has been corrected (PHP 4.4.0) *Note: I guess that's because isset() is not a function, but a keyword That was very ilustrative Rob, thanks for the info (it's the kind of thing I shouldn't forget) Satyam wrote: [···]
isset is a keyword in PHP array_key_exists() is a function. Keywords are much faster than functions due tot he overhead functions occur for setting up the stack. If you don't care about null values, use isset(). If you do, use array_key_exists(). The reason isset() doesn't return true for null entries has been described in the past. The official stance was that null is not a value. [···]
Accessing a non-existing element, doesn't create it? Thus, using isset to evaluate whether an element exists creates it, though with a null value. If you make a first pass on the array with isset, a second pass with array_key_exists would give true for all of them though isset would give the same results as in the first pass. I think this happened to me once when I went through an array with isset or isempty or some such to make some calculations and then on the second pass, when I printed it, I got lots of empty cells that were created empty in the first pass. -- Atentamente, J. Rafael Salazar Magaña Innox - Innovación Inteligente Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE rsalazar@innox.com.mx http://www.innox.com.mx


« previous php.general (#230694) next »