constant static variables

admin

Administrator
Staff member
Well, I'm hitting a new dimension of class coding I guess, becuase I'm hitting some errors that I just can't figure out. Just asking all my quesitons is going to double or triple my posts count! :( :)

Ok, I'm trying to declare some constant static variables, and I'm getting erros with all the following:

class t1{
define ('v1', 'foo');
}



class t2{
const $v2 = 'bar';
}


now I didn't expect eithero f those to work cuz there isn't a 'static' statement. I tried them in desperation after tying below:
class t3{
//static const $t3 = 'bar';
const static $t4 = 'bar';
// comment out one line & try the other

}

How do I accomplish this? just setting it as private is ok, but I'd rather throw and error if something is trying to change the value.class foo
{
const bar=42;
}
Note the $.Note the $.
Thanks for pointing that out, I sat here looking at the class thinking, 'No, I put that up there!'

maybe its just too early. I was so hoping someone had answered me as soon as I woke up, I ran straight to my computer. :)

thanks.

ps - Cool Avatar.
 
Back
Top