|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-11-10 22:26 UTC] tony2001@php.net
[2006-11-10 22:33 UTC] kevin at metalaxe dot com
[2006-11-10 22:37 UTC] kevin at metalaxe dot com
[2006-11-10 22:40 UTC] tony2001@php.net
[2006-11-10 22:54 UTC] kevin at metalaxe dot com
[2006-11-10 23:17 UTC] kevin at metalaxe dot com
[2006-11-10 23:23 UTC] tony2001@php.net
[2007-05-18 08:18 UTC] kevin at metalaxe dot com
[2007-05-18 08:32 UTC] kevin at metalaxe dot com
[2007-05-18 12:00 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
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