php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33353 update 'const' to allow a calculated value, like define()
Submitted: 2005-06-15 16:16 UTC Modified: 2006-04-03 13:59 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: joe at bigeasy dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.4 OS: linux 2.6.11
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joe at bigeasy dot com
New email:
PHP Version: OS:

 

 [2005-06-15 16:16 UTC] joe at bigeasy dot com
Description:
------------
similar to bug request 31554, http://bugs.php.net/bug.php?id=31554

can const be modified to be assigned output from an expression, similar to the define() function?


Reproduce code:
---------------
define( 'TEST1', 3+3); //works
class devil {
    const TEST2 = 3+3; //parse error unexpected '+'
    const TEST3 = (3+3); //parse error unexpected '('
    public function __construct() {
        echo TEST1;
        echo self::TEST2;
        echo self::TEST3;
    }
}
$obFoo = new devil();

Expected result:
----------------
666

Actual result:
--------------
Parse error: parse error, unexpected '+', expecting ',' or ';'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-03 13:59 UTC] tony2001@php.net
Duplicate of bug #30177.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 26 06:00:02 2025 UTC