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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC