PHP variable inheritance...why is this so hard?

Hey guys, any help would be amazing, i am programming my first php app from the bottom up and am really really struggeling with inheritance, i have never come past a language where there are so many reasons why my variable wont work.

So im trying to get this code to work:


class tst{
	static $testcase = array(1,2);
	function tstfunct(){
	 	global $testcase;
		print_r($testcase);
	}

Basically, i want to store a global class variable that can be used by every function within the class…but its really not going well, i just cant read any more PHP rubbish, i dont see why thing dosent work.

Thanks,
Nick

edit: i am fireing the function correctly, no worries about that.

ok i think i got it working, this is a bad area for php.

try:

 
class tst{ 
     private $testcase = array(1,2); 
          function tstfunct(){ 
              print_r($[COLOR=red][B]this->[/B][/COLOR]testcase); 
          }
}

Right, with that code, certainly the language is the one to blame?

$this is a reference to the current object. Unlike several other languages it’s not implicit, so you have to use it. Of course, this is noted in the manual, so you might do yourself a favour and read that first?


<?php
class Foo {
  protected $bar = 'qux';
  public function test( ) {
     return $this->bar;
  }
}
$foo = new Foo;
echo $foo->test( );
?>