|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8141 "define" as array index in class definition is ignored
Submitted: 2000-12-06 16:36 UTC Modified: 2000-12-07 05:45 UTC
From: hp at oeri dot ch Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.0.3pl1 OS: Linux 2.2.17
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hp at oeri dot ch
New email:
PHP Version: OS:


 [2000-12-06 16:36 UTC] hp at oeri dot ch
In the snippet below, the array entry "ABC"=>1 is simply ignored. An array
OUTSIDE of a class definition is fine!

    define( "ABC", 8 );
    class test {
        var $t = array( ABC => 1, 2 => 3 );
    $u = New test();
    var_dump( $u );


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-06 17:31 UTC]
Not a bug. Class variable initializers must be static; do this
in the constructor instead.

Check out the text in the manual right after the first example
on the Classes page:

Hope this helps,

 [2000-12-07 03:54 UTC]
Actually, it is a bug. It doesn't give any error, produces
undesired behaviour and leaks memory. This should be fixed
either way - or give warning/error, or work - and in either
case not to leak.
 [2000-12-07 05:45 UTC]
OK, I've fixed in CVS so that it doesn't do any stupid
things, but define() still won't work. What would happen is
exactly as if there was no define() - i.e., you get array
with key "ABC". That's the best that can be done now.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 02:01:29 2024 UTC