ID:               39466
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kevin at metalaxe dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: *
 PHP Version:      5.2.0+
 New Comment:

Again, class constants along with the classes and functions are
declared in compile time, so they can have only constant value.
Common constants are declared in runtime using define() function, which
is why it may take a result of an expression.
There is nothing to be done with that unless you're willing to rewrite
all the engine from scratch.



Previous Comments:
------------------------------------------------------------------------

[2006-11-10 23:17:07] kevin at metalaxe dot com

I've thought on this a bit more. It seems that php currently has the
idea of constants set-up a bit limited in sight. While PHP has
"constants"implimented correctly in the class scope, it doesn't
implement it in this way on the global scope. It is silly that
functionality of such a feature should change in such a drastic
manner.

If you are unwilling to change the functionality of class keyword
const, then you need to implement a method as to set a variable
read-only within a class. Which is just completely redundant in nature
and contrary to the cause.

Perhaps you could rethink how you are implementing the const keyword
and revamp it to assign a member as read-only. This might even help you
with implementing the visibility scopes (public, private, protected) to
a class constant. Because again, it is perfectly plausible to have a
constant accessible only within the scope of a single class or child
classes.

------------------------------------------------------------------------

[2006-11-10 22:54:28] kevin at metalaxe dot com

I don't understand why I'm being shrugged off as impossible. I'm asking
for functionality similar to global constants for class constants. If
you can do it for global constants, it seems only plausible that class
constants should be handled in a similar fashion.
I could find many more uses for the exact same functionality if
necessary, within the same applicable class even.

------------------------------------------------------------------------

[2006-11-10 22:40:38] [EMAIL PROTECTED]

define() is just a function. which declares constants.
I was talking about class constants et al.

------------------------------------------------------------------------

[2006-11-10 22:37:11] kevin at metalaxe dot com

Just for reference, I reread the docs for global constants set using
define(). http://us2.php.net/manual/en/function.define.php states:

Defines a named constant at runtime. See the section on constants for
more details.

------------------------------------------------------------------------

[2006-11-10 22:33:06] kevin at metalaxe dot com

Ok, if that is the case, how does the global constant MAGIC_QUOTES get
defined from the code in the description?

<?php
define( 'MAGIC_QUOTES', ( (bool)get_magic_quotes_gpc() ), true );
var_dump( MAGIC_QUOTES );
?>

prints bool(true)

We are running 3 functions there (according to the docs). One to get
the value being applied, another to cast to int and finally one to
"define" the constant.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/39466

-- 
Edit this bug report at http://bugs.php.net/?id=39466&edit=1

Reply via email to