直接上代码!
<?php
namespace App\Utils;
class BaseUtil
{
protected static $service = [];
/**
* @Method instance
*
* @static
* @return static
*/
public static function instance(): BaseUtil
{
if (!isset(self::$service[static::class]))
self::$service[static::class] = new static();
return self::$service[static::class];
}
}
然后其他功能类继承该类即可!
最后于 2023-7-31
被admin编辑
,原因: