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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx
http://www.innox.com.mx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux