#35713 [NEW]: cannot use isset or other on variables indexed by a numerical string
From: nalkat at yahoo dot com
Operating system: Linux
PHP version: 5.1.1
PHP Bug Type: Scripting Engine problem
Bug description: cannot use isset or other on variables indexed by a numerical string
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 bug report at http://bugs.php.net/?id=35713&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35713&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35713&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35713&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35713&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35713&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35713&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35713&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35713&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35713&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35713&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35713&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35713&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35713&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35713&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35713&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35713&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35713&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35713&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35713&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35713&r=mysqlcfg
Thread (12 messages)
- nalkat at yahoo dot com
- sniper@php.net#35713 [Opn->Bgs]: cannot use isset or other on variables indexed by a numerical string
- tony2001@php.net#35713 [Bgs->Opn]: cannot use isset or other on variables indexed by a numerical string
- tony2001@php.net#35713 [Opn->Bgs]: cannot use isset or other on variables indexed by a numerical string
- nalkat at yahoo dot com#35713 [Bgs->Opn]: cannot use isset or other on variables indexed by a numerical string
- tony2001@php.net#35713 [Opn]: cannot use isset or other on variables indexed by a numerical string
- nalkat at yahoo dot com#35713 [Opn]: cannot use isset or other on variables indexed by a numerical string
- nalkat at yahoo dot com#35713 [Opn]: cannot use isset or other on variables indexed by a numerical string
- tony2001@php.net#35713 [Opn->Fbk]: cannot use isset or other on variables indexed by a numerical string
- nalkat at yahoo dot com#35713 [Fbk->Opn]: cannot use isset or other on variables indexed by a numerical string
- tony2001@php.net#35713 [Opn->Asn]: cannot use isset or other on variables indexed by a numerical string
- tony2001@php.net#35713 [Asn->Csd]: cannot use isset or other on variables indexed by a numerical string