ID: 16179
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: Windows 2002
PHP Version: 4.1.2
New Comment:
the problem is that single character access to strings is still
possible using either $string[...] or $string{...},
although using {} is recommended and [] more or less deprecated
so what you did was assigning to the first character in a string
("entity" auto-converts to integer zero), and as a character position
can only take a single character it took only the "A" from the newly
assigned string
Previous Comments:
------------------------------------------------------------------------
[2002-03-20 05:26:57] [EMAIL PROTECTED]
You are mixing the number of dimensions in the array... this can lead
to strange things indeed.
What I think happens is this:
In the second assignment, the extra ["entity"] is seen as an index into
the string "DBJ...", and since "entity" evaluates to zero, the first
character of the string is changed. Because a character is expected,
the string "ABrettEntry" is converted to a char, 'A'.
You can see this if you change ["entity"] to [0] (or [1], then it
changes the second character).
It is easily circumvented by changing the first assignment to $property
[ "src" ][ "brett" ][ "filename" ] = "DBJ_20020112.db.php";
Anyway, I don't think this is a bug in multi-dim-arrays, but perhaps
the documentation is not clear? Perhaps this should be reclassified as
a documentation problem?
Cheerio, Marc.
------------------------------------------------------------------------
[2002-03-20 05:10:57] [EMAIL PROTECTED]
My php-Code:
<?
$property [ "src" ][ "brett" ] = "DBJ_20020112.db.php";
$property [ "src" ][ "brett" ][ "entity" ] = "ABrettEntry";
// ----------------------------------------
$GLOBALS[ "property" ] = $property;
echo( "AUSGABE1 ::: ".$property["src"]["brett"]["entity"]."<BR>" );
echo( "AUSGABE2 ::: ". $property [ "src" ][ "brett" ]."<BR>" );
?>
And the result of this script looks like this:
AUSGABE1 ::: A
AUSGABE2 ::: ABJ_20020112.db.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16179&edit=1