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:

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


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

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

Description:
------------
You can define a global constant based on the return of a function yet
you cannot do so for class constants.
eg. define( 'MAGIC_QUOTES', ( (bool)get_magic_quotes_gpc() ), true );

Requesting a method to assign class constants in a manner similar to
global constants

Reproduce code:
---------------
<?php
class parser
{
    const magic_quotes = (bool)get_magic_quotes_gpc();

    public my_stripslashes( $str )
    {
         if( self::magic_quotes === true )
         {
             $str = stripslashes( $str );
         }
         return $str;
    }
}
?>

Expected result:
----------------
Constant "magic_quotes" to be assigned the boolean value of
get_magic_quotes_gpc's return.

Actual result:
--------------
With boolean cast: 
Parse error: syntax error, unexpected T_BOOL_CAST in parser.php on line
4
Without boolean cast:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in
parser.php on line 4


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


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

Reply via email to