|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
29 - 25 = ?
Subscribe to this entry?

 [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 Sep 29 15:03:44 2022 UTC