Referencing different static members in inheriting classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In the static function "toHtml_table_heading" I want to use a static
array $fields, which has different content for each implementation (sub-class)


My first trial was to use self::$fields[] to access this array, but
this only sees the member of DBTable (the class where it is been used, not the inherited one).


My second trial was to pass the classnmae thru $classname and to access
the correct $fields with $classname::$fields, but that doesn't seem to work either.


// Parent class
abstract class DBTable  {
   static protected $fields = array();
   static function  toHtml_table_heading($classname) {
       $fields = $classname::$fields;
	                // ^== syntax error,
			// unexpected
			// T_PAAMAYIM_NEKUDOTAYIM (*)

      //...
   }
   //...
}

// Child class
class DBImplementation extends DBTable {
  public function intializeClass() {
     self::$fields[] = new Object(1);
     self::$fields[] = new Object(2);
  }
  function __construct() {
     intializeClass()
  }	
}

Thankyou,
André

--

(*) From Stephen Johnson:
`T_PAAMAYIM_NEKUDOTAYIM' => It's Hebrew -- it means twice colon.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux