一部のオープンソース コードでは、なぜ次のコードを使用するのですか。
$router = Cfw_Router::getInstance();
ただ使うのではなく
$rounter = new Cfw_Router();
利点はありますか?
getInstance()
:
public static function getInstance() {
if (null === self::$__instance) {
self::$__instance = new self();
}
return self::$__instance;
}