PHP code example of shanjing / dcat-admin-setting
1. Go to this page and download the library: Download shanjing/dcat-admin-setting library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shanjing / dcat-admin-setting example snippets
use Shanjing\DcatAdminSetting\Models\SystemSetting
// 比如获取站点名称
$key = 'site_info'; // 设置数据的键名
$name = 'name'; // 设置数据的 json 格式的 key
$default = '我的网站';
$siteName = SystemSetting::get($key, $name, $default);
print($siteName); // 输出:我的网站
// 也可以获取站点 key 下的所有设置
$key = 'site_info'; // 设置数据的键名
$siteInfo = SystemSetting::get($key);
print($siteInfo); // 输出:[ "name" => "我的网站", "keyword" => "技术博客,PHP 博客"]
print($siteInfo['name']); // 输出:我的网站