From:             z_rules55 at hotmail dot com
Operating system: WinXP
PHP version:      5.1.6
PHP Bug Type:     Class/Object related
Bug description:  Cannot declare a static array with an index

Description:
------------
I would have thought that I could declare a static array in a class with
an index in the declaration, but I can't. I must instead use array() to
specify the desired index and value. Nowhere in the docs, that I could
find, does it say that you can't specify an index in a static array
declaration.

I saw in another bug that PHP does not allow the use of variable data at
compile time, and I guess since static variables are dealt with at compile
time, you can't be assigning data to a variable index. But even if the
index is define()ed beforehand, it still doesn't work.

Reproduce code:
---------------
<?php
define('INDEX', 'index');
class myclass {
    // Does not with either the string 'index' or
    // the constant INDEX.
    public static $variable['index'] = 'some value';
  //public static $variable = array('index' => 'some value'); This does
work.
}
echo myclass::$variable['index'];
?>



Expected result:
----------------
some value

Actual result:
--------------
Parse error: parse error, unexpected '[', expecting ',' or ';' in ... on
line 6

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

Reply via email to