Concat Class Var

admin

Administrator
Staff member
Ok, I'm trying to concat a class var but still cannot. I know it's not possible in version 4 as the docs (<!-- m --><a class="postlink" href="http://us2.php.net/manual/en/language.oop.php#keyword.class">http://us2.php.net/manual/en/language.o ... word.class</a><!-- m -->) say so (third gray box down).. I though maybe it would work in PHP 5 but it's still a no go. Just though someone may know of a workaround or why this is not possible..?? I'm trying to do:

<?php
define('CONST_EX', 'test');
class Test {
// I want this to be 'testtest'
static $example = CONST_EX.'test';
}
// Should print testtest
print(Test::$example);
?>you can't use static to declare a class variable. you can do const foo = 'bar' . 'baz'; but not static.I've tried that to and just a regular class var. Just seems like you can't concat anything in the var declaration. Are you sure about the static thing? There is documentation on php.net and I tried it out (without concating). Check it out, about 2/3 down. <!-- m --><a class="postlink" href="http://www.php.net/zend-engine-2.php">http://www.php.net/zend-engine-2.php</a><!-- m -->
 
Back
Top