php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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 );
?>        

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-06 17:31 UTC] torben@php.net
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:

  http://www.php.net/manual/language.oop.php


Hope this helps,

Torben
 [2000-12-07 03:54 UTC] stas@php.net
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] stas@php.net
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 Dec 22 01:01:30 2024 UTC