Disclaimer: Yes, I am forced to support PHP 4.3.0. I know that he is dead. No, I can’t update it, because I am dealing with several servers, some of which I don’t have.
Well, since I cannot use self::, since it is specific to PHP5, how should I use statics in the PHP4 class? Until now, in my opinion, I can use the keyword static, except only in the context of the function, I saw another method that uses $ _GLOBALS, but I do not think that I will use it.
Just for us to be on the same page, I need to access these PHP5 statistics in 4 format:
public static $_monthTable = array(
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
public static $_yearTable = array(
1970 => 0, 1960 => -315619200);
So far, I have come up with my own function, which basically sets a static variable if not found, and I rigidly set all my static properties. However, I am not quite sure how I can refer to this statics in the anther method in the same class, assuming that it is not created and that no constructor starts, that is, I can not use it $this.
class DateClass {
function statics( $name = null ) {
static $statics = array();
if ( count( $statics ) == 0 ) {
$statics['months'] = array(
'Jan', 'Feb'
);
}
if ( $name != null && array_key_exists($name, $statics ) ) {
return $statics[$name];
}
}
};
var_dump( DateClass::statics('months') );
Question No. 1: Is this possible? Should I try to use a different method?
Question # 2: How can I refer to statics from a method in the same class? I tried __CLASS__::statics, but I think that __CLASS__this is just a string, so I do not call the method.
.. , Apache2 +/IIS6 +, PHP4.3.0 PHP 5.2, OSX/Linux/Windows.