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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: e dot vandeoudeweetering at marcanti dot esprit-sg dot
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 17:01:58 2024 UTC