私はFuelPHPがどのように書かれたかを理解しようとしています。そして私はOOPをあまり知らないので、このクラスが https://github.com/fuel/core/blob/master/classes/dateのときに戸惑います。 php
これが私が理解していない方法です:
public static function _init()
{
static::$server_gmt_offset = \Config::get('server_gmt_offset', 0);
// some code here
}
public static function factory($timestamp = null, $timezone = null)
{
$timestamp = is_null($timestamp) ? time() + static::$server_gmt_offset : $timestamp;
$timezone = is_null($timezone) ? \Fuel::$timezone : $timezone;
return new static($timestamp, $timezone);
}
protected function __construct($timestamp, $timezone)
{
$this->timestamp = $timestamp;
$this->set_timezone($timezone);
}
最初に何と呼ばれますか?__counctructは何をしますか?ファクトリとは何ですか、使用すると何が返されますか?それは再び自分自身を呼び出しますか?クラスの初期化後に_initが呼び出されますか?私は本当に困惑しています、誰かが私を理解するのを手伝ってくれますか?ありがとう