php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50184 Constants can be redefined
Submitted: 2009-11-16 01:44 UTC Modified: 2009-11-25 10:01 UTC
From: goatlabs at gmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.0 OS: OSX 10.6.2; Debian Linux 5.0.3
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: goatlabs at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-16 01:44 UTC] goatlabs at gmail dot com
Description:
------------
define() constants can be modified if originally defined case-sensitive

Reproduce code:
---------------
define('TEST', 'foo', true);
var_dump(TEST);
define('TEST', 'bar');
var_dump(TEST);





Expected result:
----------------
string(3) "foo"
string(3) "foo"

Actual result:
--------------
string(3) "foo"
string(3) "bar"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-16 03:59 UTC] goatlabs at gmail dot com
Note: the description should read:

define() constants can be modified if originally defined "case-INsensitive"
 [2009-11-16 09:35 UTC] jani@php.net
From manual notes:

A note on redefining:

Constants can't be redefined:

$ php -r "define('A', 1); var_dump('A'); define('A', 2); var_dump('A');";
string(1) "A"
PHP Notice:  Constant A already defined in Command line code on line 1
string(1) "A"

But using the case insensitive setting shows that the internal
representation is lower case:

$ php -r "define('A', 1, true); var_dump('A'); define('A', 2); var_dump('A');";
string(1) "A"
string(1) "A"

Note the lower case 'a' in the second define() here:
$ php -r "define('A', 1, true); var_dump('A'); define('a', 2); var_dump('A');";
string(1) "A"
PHP Notice:  Constant a already defined in Command line code on line 1
string(1) "A"

(Short version: Yes, but no)
 [2009-11-25 09:59 UTC] svn@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=291296
Log: Case-insensitive are lower-case (bug #50184)
 [2009-11-25 10:01 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 28 05:00:03 2025 UTC