#23532 [NEW]: Associative Array Problem Problem in PHP5 and inconsistency in 4.3.1
From: mjsabby at yahoo dot com
Operating system: WinNT 5.0 (2K), RHL 7.3
PHP version: 5CVS-2003-05-07 (dev)
PHP Bug Type: Variables related
Bug description: Associative Array Problem Problem in PHP5 and inconsistency in 4.3.1
There is a very strange error when using associative array naming within
quotes, have a look here. This is based on the PHP5 May 5th 17:30GMT
build.
In PHP 4.3.1
<?php
$arr = array("hello" => "hello world");
echo "$arr['hello']";
?>
The above code does not output any information. The quotes have something
to do with this.
<?php
$arr = array("hello" => "hello world");
echo $arr['hello'];
?>
This above code fragment will print "hello world".
The usage that is consistent always is not using single quotes :
<?php
$arr = array("hello" => "hello world");
echo "$arr[hello]"; // echo $arr[hello]; executes!
?>
The above is still acceptable and does not generate any error. Not even a
notice if it is turned on, so it most likely an output related bug.
Now coming to PHP5!
<?php
$arr = array("hello" => "hello world");
echo "$arr[hello]"; echo $arr[hello]; exectues!
?>
The above code works fine, with and without the quotes.
<?php
$arr = array("hello" => "hello world");
echo "$arr['hello']"; // echo $arr['hello']; executes!
?>
This code does not work if the quotes are present, works when the quotes
are removed!
--
Edit bug report at http://bugs.php.net/?id=23532&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23532&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23532&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23532&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23532&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23532&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23532&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23532&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23532&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23532&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23532&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23532&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23532&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23532&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23532&r=gnused
Thread (2 messages)
- mjsabby at yahoo dot com