Click to See Complete Forum and Search --> : Concat Class Var


rpanning
05-20-2004, 06:07 PM
Ok, I'm trying to concat a class var but still cannot. I know it's not possible in version 4 as the docs (http://us2.php.net/manual/en/language.oop.php#keyword.class) 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);
?>

Moonglobe
05-20-2004, 10:23 PM
you can't use static to declare a class variable. you can do const foo = 'bar' . 'baz'; but not static.

rpanning
05-21-2004, 01:21 AM
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. http://www.php.net/zend-engine-2.php