ID: 35713
Updated by: sniper@php.net
Reported By: nalkat at yahoo dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.1.1
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2005-12-16 17:30:38] nalkat at yahoo dot com
Description:
------------
When dealing with arrays indexed by a numerical string (i.e.
$array['1']) and then attempting to use isset or similar on the value,
results are not as expected.
As you can see from the example below, it would be impossible to use
something such as:
$opts = getopt("1:2:a:b:");
if (isset($opts['1'])) {
do_something();
}
if (isset($opts['2'])) {
do_something_else();
}
if (isset($opts['a'])) {
echo "works\n";
}
...
...
Reproduce code:
---------------
<?
// test.php
$opts = getopt("1:2:3:4:a:");
if (isset($opts['1'])) {
echo "it worked for 1!\n";
}
if (isset($opts['a'])) {
echo "it worked for a!\n";
}
var_dump ($opts);
?>
(host)# php -q test.php -1 hi -a bye
Expected result:
----------------
EXPECTED:
-----------
it worked for 1!
it worked for a!
array(2) {
["1"]=>
string(2) "hi"
["a"]=>
string(3) "bye"
}
Actual result:
--------------
ACTUAL:
-----------
it worked for a!
array(2) {
["1"]=>
string(2) "hi"
["a"]=>
string(3) "bye"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35713&edit=1