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

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.


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

[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.

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

[2006-11-10 22:26:50] [EMAIL PROTECTED]

That's not possible, as constants are declared at compile time, while
functions are executed at runtime.

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

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