Re: Static Array declaration within class PHP5
| From: | Richard Lynch | Date: | Fri, 21 Jan 2005 20:05:30 +0000 |
| Subject: | Re: Static Array declaration within class PHP5 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-206981@lists.php.net to get a copy of this message | ||
Marek wrote:
> Hello
>
> I'm trying to create a public static array within a class.(PHP5).
>
> First - the following fails:
>
> class yadayada {
> public static $tester[0]="something";
> public static $tester[1]="something 1";
>
> Second - However the following works:
>
> class yadayada {
> public static $tester = array (0 => "something", 1 >="something
> 1");
>
> My question is this: I have an array that has about some 150 different
> values and using the second example would get very very messy, is there
> another method of doing this ? The first example(which fails) is the
> cleanest, is there anything I can do ?
You could set the elements one by one in a constructor, I do believe.
You *MIGHT* be able to do:
$foo[0] = '0';
$foo[1] = '1';
$foo[2] = '2';
.
.
.
class yadayada {
public static $tester = $foo;
}
but I doubt it...
--
Like Music?
http://l-i-e.com/artists.htm