Req #10527 [Opn->Wfx]: Declare constant variables
| From: | krakjoe@php.net | Date: | Tue, 17 Feb 2015 08:38:57 +0000 |
| Subject: | Req #10527 [Opn->Wfx]: Declare constant variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190733@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=10527&edit=1
ID: 10527
Updated by: krakjoe@php.net
Reported by: jnutzman at yahoo dot com
Summary: Declare constant variables
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
I don't think a constant variable makes sense in principle.
We don't have the concept of a symbol in user land PHP.
In C (or others), where everything is a symbol, functions, classes, named variables, it makes sense
for a symbol to be constant.
In PHP, we don't have symbols, we have constants, variables, classes, and functions, they are
distinct and non-overlapping.
To change this would be a significant and complicated change, of the kind that requires and RFC.
I'm therefore going to mark this bug as won't fix, it can still be found if some future
RFC requires it for reference.
Sorry about the wait :)
Previous Comments:
------------------------------------------------------------------------
[2001-04-27 12:37:44] jnutzman at yahoo dot com
PHP 4 doesn't seem to have the capability to define variables of all types as being constants.
An example of this could be:
$stuff = (const)array('1','2');
or
$stuff = const($stuff);
An error would be generated if the script later tried to:
$stuff = array('3','2');
This is *not* the same as CONSTANTS like TRUE and FALSE.
This would be extremely useful with sessions, so other programmers don't clobber important
session variables that shouldn't change.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=10527&edit=1