From: kevin at metalaxe dot com
Operating system: *
PHP version: 5.2.0
PHP Bug Type: Feature/Change Request
Bug description: Expaned Class constants to accept return of function value
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 bug report at http://bugs.php.net/?id=39466&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39466&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39466&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39466&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39466&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39466&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39466&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39466&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39466&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39466&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39466&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39466&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39466&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39466&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39466&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39466&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39466&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39466&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39466&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39466&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39466&r=mysqlcfg