Bug #14064: Arrays defined as object properties treat defined constants differently.

From: Date: Wed, 14 Nov 2001 22:38:34 +0000
Subject: Bug #14064: Arrays defined as object properties treat defined constants differently.
Groups: php.dev 
Request: Send a blank email to php-dev+get-70494@lists.php.net to get a copy of this message
From: andre@fscinternet.com Operating system: i386-redhat-linux-gnu PHP version: 4.0.6 PHP Bug Type: Class/Object related Bug description: Arrays defined as object properties treat defined constants differently. It appears that using defined constants to index an array within a class results in different behaviour than arrays defined without. Within a class, the array treats the constant as a string literal, whereas in a regular array definition, the constant is properly evaluated. Which of the two is the "correct" behaviour, and why do they differ between contexts? Is there a way to get the results of Situation A in Situation B? --(snip)-- <?php define( 'TEST1', 1 ); define( 'TEST2', 2 ); define( 'TEST3', 3 ); // Situation A $aTest = array( TEST1 => 'TEST1', TEST2 => 'TEST2', TEST3 => 'TEST3' ); print_r( $aTest ); ######################################################################### // Situation B class Test { var $aTest2 = array( TEST1 => 'TEST1', TEST2 => 'TEST2', TEST3 => 'TEST3' ); } $oTest = new Test; print_r( $oTest ); ?> -- Edit bug report at: http://bugs.php.net/?id=14064&edit=1

« previous php.dev (#70494) next »