#23384 [NEW]: static array accessed from subclass
| From: | thixit at yahoo dot com | Date: | Mon, 28 Apr 2003 16:44:23 +0000 |
| Subject: | #23384 [NEW]: static array accessed from subclass | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-38621@lists.php.net to get a copy of this message | ||
From: thixit at yahoo dot com
Operating system: Windows 98
PHP version: 5CVS-2003-04-28 (dev)
PHP Bug Type: Scripting Engine problem
Bug description: static array accessed from subclass
The following codes didn't work as expected. There're two problems that I
don't understand.
First, PHP doesn't know about defined constant if test() is called from
subclass.
<?php
define('TEN', 10);
class Foo {
function test() {
static $arr = array(TEN => 'ten');
print_r($arr);
}
}
class Bar extends Foo {
}
Foo::test(); // output: Array([10] => ten)
Bar::test(); // output: Array([TEN] => ten)
?>
Second, as commented, it doesn't know about const TEN too.
<?php
class Foo {
const TEN = 10;
function test() {
// --- PHP will complain about this
// static $arr = array(TEN => 'ten');
// --- This line cause $arr to be an empty array
// without any error
static $arr = array(Foo::TEN => 'ten');
print_r($arr);
}
}
Foo::test(); // output: Array()
?>
--
Edit bug report at http://bugs.php.net/?id=23384&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23384&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23384&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23384&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23384&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23384&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23384&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23384&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23384&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23384&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23384&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23384&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23384&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23384&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23384&r=gnused