php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23951 Defines not working in inherited classes
Submitted: 2003-06-02 06:01 UTC Modified: 2003-06-09 12:03 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sbecker at justseven dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4CVS-2003-06-02 (stable) OS: Linux 2.4
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: sbecker at justseven dot de
New email:
PHP Version: OS:

 

 [2003-06-02 06:01 UTC] sbecker at justseven dot de
This bug is in some way the same as reported in #14064.

I got the following code:

<?php

define('FOO1', 1);
define('FOO2', 2);

class A {
    
    var $a_var = array(FOO1=>'foo1_value', FOO2=>'foo2_value');
    
}

class B extends A {
 
    var $b_var = 'foo';   
            
}

$a = new A;
$b = new B;

print_r($a);
print_r($b);

?>

Class A is doing fine but in Class B the Zend-Engine converts my constants to strings, is that what you want?

-
Stefan

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-02 06:05 UTC] derick@php.net
Interesting behavior... I could replicate this and it's definitely a bug.
 [2003-06-04 17:37 UTC] wez@php.net
You can't use define()'s as constant scalar initializers; this behaviour is documented in the manual somewhere.
To initialize the array that way, do it in your object constructor.
 [2003-06-09 12:03 UTC] wez@php.net
Fixed in CVS.
You can apply this patch to make it work for you, or try the next stable snapshot.
http://www.php.net/~wez/define_inherit.diff

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC