php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67104 Behaviour of defining constants is inconsistent and misleading
Submitted: 2014-04-21 23:57 UTC Modified: 2018-09-12 23:58 UTC
Votes:4
Avg. Score:3.8 ± 1.6
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: ss23 at ss23 dot geek dot nz Assigned: nikic (profile)
Status: Assigned Package: *General Issues
PHP Version: Irrelevant OS:
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: ss23 at ss23 dot geek dot nz
New email:
PHP Version: OS:

 

 [2014-04-21 23:57 UTC] ss23 at ss23 dot geek dot nz
Description:
------------
The current behaviour is very confusing.

Test script:
---------------
<?php

define('TRUE', false);

var_dump(true);
var_dump(TRUE);
var_dump(constant('TRUE'));
var_dump(constant('true'));

Expected result:
----------------
Anything but this. An E_ERROR (or even E_WARNING) on the initial define would be enough.

Actual result:
--------------
bool(true)
bool(true)
bool(false)
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-05-07 08:58 UTC] iam4webwork at hotmail dot com
The following result occurs for PHP4.3.0-5.1.2 (see http://3v4l.org/M1ZrQ#v430)

bool(true)
bool(false)
bool(false)
bool(true)

These results seem fine.  What changed and why? I agree that there sh/b s.thing in case s.one tries to override a built-in constant.
 [2018-09-12 23:58 UTC] nikic@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: nikic
 [2018-09-12 23:58 UTC] nikic@php.net
This will be resolved in PHP 8 by https://wiki.php.net/rfc/case_insensitive_constant_deprecation. Redefinition checks for case-insensitive constants currently do not work correctly and will not be fixed until support is removed entirely.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Dec 14 09:01:25 2018 UTC