[PHP] syntax error in class
Hello guys, I encountered a syntax error, and cannot figure out the reason, for example: == CODE == 1:?php 2:$opts = array ('header'='str1'.'str2'); 3:? === Works fine, but when I try to put it into a class, say: == CODE == 1:?php 2:class Test 3:{ 4:var $opts = array ('header'='str1'.'str2'); 5:} 6:? == OUTPUT == Parse error: syntax error, unexpected '.', expecting ')' in C:\Documents and Settings\Administrator\Local Settings\Temp\VI42E5.tmp on line 4 PHP Parse error: syntax error, unexpected '.', expecting ')' in C:\Documents and Settings\Administrator\Local Settings\Temp\VI42E5.tmp on line 4 I got the syntax error. Why? My php version: D:\php -version PHP 5.3.1 (cli) (built: Nov 19 2009 10:17:43) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies I'm currently not on this list, please Cc your comment to me. Thanks in advance. -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax error in class
Dasn wrote: I got the syntax error. Why? Read the first paragraph on the following page. http://us3.php.net/manual/en/language.oop5.properties.php [quote] ... This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated. [/quote] Basically, anything that requires the concatenation of string parts or usage of variables is not allowed. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax error in class
2010/2/11 Jim Lucas li...@cmsws.com Dasn wrote: I got the syntax error. Why? only constant literal is allowed. You can think that it is static complie but not on runtime . Regards, Eric, Read the first paragraph on the following page. http://us3.php.net/manual/en/language.oop5.properties.php [quote] ... This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated. [/quote] Basically, anything that requires the concatenation of string parts or usage of variables is not allowed. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php