ID: 35713 Updated by: [EMAIL PROTECTED] Reported By: nalkat at yahoo dot com -Status: Assigned +Status: Closed Bug Type: CGI related Operating System: Linux PHP Version: 5.1.1 Assigned To: tony2001 New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2005-12-16 20:45:06] [EMAIL PROTECTED] So, the problem exists only in CLI. I need to test the patch.. ------------------------------------------------------------------------ [2005-12-16 20:33:05] nalkat at yahoo dot com Tony: Ok this is what I am seeing. When I attempt to assign the numerical string index to the array manually PHP converts that numerical value to an actual number. It would appear that you are correct that getopt is causing the problem, however, I still feel that it is a PHP core problem that is allowing this behavior to occur. try this snippet: <?php $array = array(); $array['1'] = "blah"; if (isset($array['1'])) { echo "the test condition worked\n"; } var_dump($array); unset ($array); $array = getopt("1:"); if (isset($array['1'])) { echo "the test condition worked\n"; } var_dump($array); ?> You will notice that the test condition fails when the variable is being assigned by getopt, but not when it is assigned manually. You will also notice in the output of the var_dumps that the manual assignment converts the numerical string to an actual number whereas the getopt version does not. You tell me.. is this a PHP problem of allowing the numerical string index to be assigned or merely a getopt problem where this is actually occuring? At anyrate, should I be able to use getopt with a numerical command-line argument? Is there some kind of work around? ------------------------------------------------------------------------ [2005-12-16 20:04:55] [EMAIL PROTECTED] >you can create an array with a numerical string index > value, and you will still have the same problem. Eh? What are you talking about? >and if you will notice, from your example code snippet, >you are not doing a test on the value of the array element. Did you try to execute it? What kind of notice you get with this code? <?php $array = array(1=>1); var_dump(isset($array["1"])); var_dump(isset($array[1])); ?> ------------------------------------------------------------------------ [2005-12-16 19:59:44] nalkat at yahoo dot com and if you will notice, from your example code snippet, you are not doing a test on the value of the array element. You are merely assigning it. Attempt to do some kind of validation... does it work? ------------------------------------------------------------------------ [2005-12-16 19:56:08] nalkat at yahoo dot com I dont think its a problem of getopt adding numerical string indexes, because you can create an array with a numerical string index value, and you will still have the same problem. If what you say truely is the case, then it is still a problem with the PHP core itself allowing this action. I think the real problem here is that when you are attempting to access an array element with a numerical string as the index value, PHP is not seeing it as a string when enclosed in quotes, but rather it is converting the numerical string to a numerical literal. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/35713 -- Edit this bug report at http://bugs.php.net/?id=35713&edit=1
