ID: 37230
Updated by: [EMAIL PROTECTED]
Reported By: teveritt22 at te-server dot org
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Windows
PHP Version: 5.1.2
New Comment:
No bug.
Previous Comments:
------------------------------------------------------------------------
[2006-04-29 11:31:06] [EMAIL PROTECTED]
This is not really realted to the other mentioned bug AFAICS.
It actually is expected behaviour, you should not use non-scalars as
array index (objects, resources etc.).
------------------------------------------------------------------------
[2006-04-28 02:54:44] teveritt22 at te-server dot org
Description:
------------
When using a variant (e.g. new VARIANT(3)) as an index for an array, it
generates "Warning: Illegal offset type". I looked around and not sure
if this is a bug or is expected behavior, but the only way to get
around it is to convert the variant into an integer (e.g sprintf).
In addition, print_r of the variant returns "variant Object #" as
explained in PHP Bug #35956. Bug #35956 states that downloading the
latest PHP solves the issue, however, the issue is still seen with the
latest php version.
Reproduce code:
---------------
<?php
$v = new VARIANT(3);
print "The value is " . $v . "<br/>";
$arry = array("first","second","third","fourth","fifth");
echo $arry[$v] . "<br/>"; // This does not work
echo print_r($v) . "<br/>"; // This does not work
$v = 3;
echo $arry[$v]. "<br/>"; // This works
$v = new VARIANT(3);
echo $arry[sprintf($v)]; // This works
?>
Expected result:
----------------
The value is 3
fourth
fourth
fourth
fourth
Actual result:
--------------
The value is 3
Warning: Illegal offset type in C:\Documents and
Settings\teveritt\Desktop\online classes
demos\sqlserver\moodle-latest-15\moodle\test.php on line 7
variant Object 1
fourth
fourth
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37230&edit=1