php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13138 constants behave weird in static hash arrays
Submitted: 2001-09-04 13:23 UTC Modified: 2001-09-05 16:18 UTC
From: jack at mobil dot cz Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: linux
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: jack at mobil dot cz
New email:
PHP Version: OS:

 

 [2001-09-04 13:23 UTC] jack at mobil dot cz
I think the following piece of code behaves sort of weird:

<?
    define ('A', 1);

    function test()
    {
	$a = array(1 => true);
	static $stat_a = array(A => true);

	var_dump($a);
	var_dump($stat_a);
    }
    test();
?>

result is:
array(1) {
  [1]=>
  bool(true)
}
array(1) {
  ["A"]=>
  bool(true)
}

I'm not sure whether static variables are supposed to evaluate expressions but even if they were not, the engine should at least issue a warning.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-04 16:51 UTC] joey@php.net
Please try a more recent version of PHP. 4.0.7RC1 gives
me:
array(1) {
  [1]=>
  bool(true)
}
array(1) {
  [1]=>
  bool(true)
}
 [2001-09-05 16:18 UTC] joey@php.net
Great. If you still have problems, please reopen.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 20:01:46 2025 UTC