常用类库
-
获取指定年份的开始时间和结束时间
获取指定年份的开始时间和结束时间// 获取指定年份的开始时间和结束时间public function getYearStartEnd($year){ $start = strtotime('January 1st ' . $year); $end = strtotime('December 31st ' . $year . ' 23:59:59'); return [ 'start' => $start, 'end' => $end ];}
-
获取指定年指定月的天数
获取指定年指定月的天数// 获取指定年指定月的天数public function getDaysInMonth($year, $month){ if ($month < 1 || $month > 12) { return 0; } if ($year < 1) { return 0; } return cal_days_in_month(CAL_GREGORIAN, $month, $year);}
-
自定义站点地图的xml文件
1 编写Sitemap类<?phpclass Sitemap{ public $encoding; // xml编码 /** * 初始化 * @param string $encoding xml编码 */ public function __construct($encoding = 'UTF-8') { $this->encoding = $encoding; } /** * 创建RSS文件内容 * @param array $items 文章内容 * return string rss字符串内容 */ public function createSiteMap($items)
-
自定义RSS的xml文件
1 编写RSS类<?phpclass Rss{ public $title; // 频道的标题 public $link; // 频道的链接 public $description; // 频道的描述 public $language; // 频道的语言 public $encoding; // xml编码 public $rss_url; // rss地址 /** * 初始化 * @param string $title 频道标题 * @param string $link 频道链接 * @param string $description 频道描述 * @param string $
-
Mysql还原类
<?phpnamespace maowenke\mysql;/** * Mysql还原类 */class Restore { /** * 数据库配置 * @var array */ protected $database = []; /** * pdo连接对象 * @var null */ protected $pdo = null; protected $error = ''; /** * 构造方法 * @param array $database * [ * 'username'=>'', * 'password'=>'', * 'database'=>'', *
-
Mysql备份类
<?phpnamespace maowenke\mysql;/** * Mysql备份类 */class Backup { /** * 数据库配置 * @var array */ protected $database = []; /** * pdo连接对象 * @var null */ protected $pdo = null; /** * 要备份的数据表 * @var array */ protected $tables = []; /** * 输出目录 /结尾 * @var string */ protected $output_path = ''; /** * 文件名 * @v