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
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.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-03 13:59 UTC] tony2001@php.net
Duplicate of bug #30177.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 13:01:35 2024 UTC