|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80089 Use of undefined constant is suddenly fatal
Submitted: 2020-09-10 22:27 UTC Modified: 2020-09-10 22:29 UTC
From: s dot wisselink at iwink dot nl Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 8.0.0beta3 OS: Debian
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.
Block user comment
Status: Assign to:
Bug Type:
From: s dot wisselink at iwink dot nl
New email:
PHP Version: OS:


 [2020-09-10 22:27 UTC] s dot wisselink at iwink dot nl
In php8.0.0beta3, referencing an undefined constant throught the `constant` function is fatal, whereas in php7.x it is not.

Test script:
$ php -v
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
$ php -r "echo @constant('MYCONSTANT2');"
(no output)

whereas in php8

$ php -v
PHP 8.0.0beta3 (cli) (built: Sep  4 2020 20:24:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
$ php -r "echo @constant('MYCONSTANT2');"

Fatal error: Uncaught Error: Undefined constant "MYCONSTANT2" in Command line code:1
Stack trace:
#0 Command line code(1): constant('MYCONSTANT2')
#1 {main}
  thrown in Command line code on line 1

whereas the docs say: " [constant()] Returns the value of the constant, or NULL if the constant is not defined." 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-10 22:29 UTC]
-Status: Open +Status: Not a bug
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Aug 11 08:05:57 2022 UTC