|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28005 use of per class constants
Submitted: 2004-04-15 07:28 UTC Modified: 2004-04-15 10:01 UTC
From: e dot vandeoudeweetering at marcanti dot esprit-sg dot Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.0RC1 OS: windows2000 (5.00.2195) sp4
Private report: No CVE-ID: None
 [2004-04-15 07:28 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
This bug is related to: Bug #27523

It is not possible to use a class constant, without a reference to its OWN class!

see reproduce code:

Another problem is that the function returns the name of the constant instead of it's value!

Reproduce code:

class Test {
  const TEMP = "hi";
  function printConst() {
    print "const Test::TEMP = " . Test::TEMP . "\n"; //works!
    print "const TEMP       = " . TEMP . "\n"; //produces notice

$t = new Test();
$t -> printConst();


Expected result:
The following output should be printed:

const Test::TEMP = hi
const TEMP       = hi

Actual result:
const Test::TEMP = hi
PHP Notice:  Use of undefined constant TEMP - assumed 'TEMP' in C:\Temp\test.php on line 8
const TEMP       = TEMP


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-15 10:01 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 04:01:30 2024 UTC