From:             teveritt22 at te-server dot org
Operating system: Windows
PHP version:      5.1.2
PHP Bug Type:     Unknown/Other Function
Bug description:  array index of type variant fail

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 bug report at http://bugs.php.net/?id=37230&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37230&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=37230&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37230&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37230&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37230&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37230&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37230&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37230&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37230&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37230&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37230&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37230&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37230&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37230&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37230&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37230&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37230&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37230&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37230&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37230&r=mysqlcfg

Reply via email to