|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67007 Incorrect (inaccurate) PHP Notice regarding the use of constants
Submitted: 2014-04-02 11:38 UTC Modified: 2017-05-19 10:57 UTC
Avg. Score:4.0 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:3 (75.0%)
From: edvinas at pnd dot io Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: 5.5.10 OS: Linux
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: edvinas at pnd dot io
New email:
PHP Version: OS:


 [2014-04-02 11:38 UTC] edvinas at pnd dot io
PHP provides inaccurate NOTICE message regarding constants on class initialization. When you initialize new class, the error message does not point the line in the class which causes said error message, but points to a line where Class is initialized instead.

Test script:
// Foo.php
class Foo { 

    const BAR = 1;
    protected $message = BAR; // <- this line is intentionally incorrect

    public function __construct($message) {
        $this->message = $message;
        echo "Initialized with {$this->message}";

// test.php
include 'Foo.php';
$var = new Foo(Foo::BAR);

Expected result:
Expected result:
Notice: Use of undefined constant BAR - assumed 'BAR' in Foo.php on line 5

Actual result:
Actual result:
Notice: Use of undefined constant BAR - assumed 'BAR' in test.php on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-06 01:39 UTC]
-Status: Open +Status: Verified
 [2017-05-19 10:41 UTC] jhabdas at gmail dot com
Appears to be dupe of
 [2017-05-19 10:57 UTC]
-Status: Verified +Status: Duplicate -Package: *General Issues +Package: Scripting Engine problem
 [2017-05-19 10:57 UTC]
Dupe-ing this one because the other has commentary.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Apr 02 02:03:38 2023 UTC