How can I define an array inside a PHP class scope in PHP4 -


i need define constant array within scope of class, used statically (i.e. not creating instance of class). here sample code works in php5, not in php4:

class mytest {     static $arr = array(100, 200);     function test() {         print_r(mytest::$arr);     } }  mytest::test(); 

how can change code works in php4 (4.4.9-pl0-gentoo)?

remarks:

  • it has work in php4.
  • i need access array preferrably in static manner, without creating instance. requirement dropped.
  • i cannot use globals code has work within phpunit unit-testing. when doing so, array defined global in header of file not seen within unittest.
  • i want define array (containing constant values) outside function being used. if no other possibility exists solve question, requirement dropped well.

class mytest {     public function getarray() {         return array(100, 200);     } } 

not pretty, can call mytest::getarray() without creating instance (or $this->getarray() inside class) retrieve data.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -