我试图理解 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);
}
什么叫先?__construct 做什么?什么是工厂,什么时候被使用,它返回什么——它会再次调用自己吗?初始化类后是否调用_init?我真的很困惑,有人可以帮助我理解吗?谢谢