php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #10022 Constants not handled in arrays defined in class declaration
Submitted: 2001-03-27 09:54 UTC Modified: 2001-06-27 02:09 UTC
From: cri at mindpass dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.4pl1 OS: Linux
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cri at mindpass dot com
New email:
PHP Version: OS:

 

 [2001-03-27 09:54 UTC] cri at mindpass dot com
<?php

//
//  The following produces a warning
//

error_reporting(15);

define("A", 1);
define("B", 2);
define("C", 3);

class Example {
    
    var $hash = array(A  => "test1",
		      B  => "test2",
		      C  => "test3");
    
    var $otherHash;
    
    function Example() {
	$this->otherHash = array(A   => "test1",
				 B  => "test2",
				 C   => "test3");
    }

}

$example = new Example;

echo "<hr>Trying \$example->hash[B]:<br>";
echo $example->hash[B];

echo "<hr>Trying \$example->otherHash[B]<br>";
echo $example->otherHash[B];

echo "<hr>Dump of \$example->hash<br>";
print_r($example->hash);

echo "<hr>Dump of \$example->otherHash<br>";
print_r($example->otherHash);
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-27 10:26 UTC] sniper@php.net
Check the last user entry on this page:
http://www.php.net/manual/en/language.constants.php

Reclassified as documentation problem. 

--Jani

 [2001-06-27 02:09 UTC] danbeck@php.net
This is already explained in http://www.php.net/manual/en/language.oop.php, but I did go ahead and add an example of using array() in the list of things that won't work.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 23:01:30 2024 UTC