Req #67104 [Asn->Csd]: Behaviour of defining constants is inconsistent and misleading
| From: | nikic@php.net | Date: | Thu, 09 May 2019 09:55:04 +0000 |
| Subject: | Req #67104 [Asn->Csd]: Behaviour of defining constants is inconsistent and misleading | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220793@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67104&edit=1
ID: 67104
Updated by: nikic@php.net
Reported by: ss23 at ss23 dot geek dot nz
Summary: Behaviour of defining constants is inconsistent and
misleading
-Status: Assigned
+Status: Closed
Type: Feature/Change Request
Package: *General Issues
PHP Version: Irrelevant
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Now prints the following on PHP 8, as expected:
Notice: Constant TRUE already defined in /home/nikic/php-src/t011.php on line 2
bool(true)
bool(true)
bool(true)
bool(true)
Previous Comments:
------------------------------------------------------------------------
[2018-09-12 23:58:29] 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.
------------------------------------------------------------------------
[2014-05-07 08:58:14] 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.
------------------------------------------------------------------------
[2014-04-21 23:57:23] 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)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67104&edit=1