#44587 [Opn->Bgs]: Problems whene asking if a key of an array isset, and the variable is not array

From: Date: Wed, 02 Apr 2008 00:03:35 +0000
Subject: #44587 [Opn->Bgs]: Problems whene asking if a key of an array isset, and the variable is not array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-123837@lists.php.net to get a copy of this message
ID: 44587 Updated by: felipe@php.net Reported By: francesco at facconi dot eu -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux 2.6.18-6-686 PHP Version: 5.2.5 New Comment: This is expected, the string key is converted to integer. Previous Comments: ------------------------------------------------------------------------ [2008-04-01 10:48:21] francesco at facconi dot eu Description: ------------ I was evaluating a variable with isset. I don't know what kind of variable it is before evaluating. If I do a isset of a key of an array, and the variable is NOT an array, I receive a true response. I think this is not a good result. Reproduce code: --------------- function verify($var) { if (isset($var['key'])) { echo "OK"; } else { echo "NO"; } return; } verify ('asdfghjkl'); verify (array('key'=>'1', 'option'=>'2'); verify (array('action'=>'1', 'option'=>'2'); Expected result: ---------------- ## verify ('asdfghjkl'); NO ## verify (array('key'=>'1', 'option'=>'2'); OK ## verify (array('action'=>'1', 'option'=>'2'); NO Actual result: -------------- ## verify ('asdfghjkl'); OK ## verify (array('key'=>'1', 'option'=>'2'); OK ## verify (array('action'=>'1', 'option'=>'2'); NO ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44587&edit=1

« previous php.bugs (#123837) next »