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: -
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:
Status: Open Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC