php.net |  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
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:
MUST BE VALID
Solve the problem:
29 + 25 = ?
Subscribe to this entry?

 
 [2004-04-15 07:28 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Description:
------------
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:
---------------
<?php

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 22:01:28 2024 UTC