1.jpg
webconfig.php 配置调用
'extra_config_list' => ['web'],
<?php return ['WEB_NAME'=>'111','WEB_HOST'=>'http://www.baidu.com','WEB_BEIAN'=>'123456'];
<form class="layui-form" action="{:url('sys_add','','')}" method="post">
<input type="text" name="WEB_NAME">
<input type="text" name="WEB_HOST">
<input type="text" name="WEB_BEIAN">
</form>
public function sys_add()
{
$path = APP_PATH . '/admin/extra/web.php';
$file = (include $path);
$config = array(
'WEB_NAME' => input('WEB_NAME')
);
$res = array_merge($file, $config);
$str = '<?php return [';
foreach ($res as $key => $value) {
$str .= '\'' . $key . '\'' . '=>' . '\'' . $value . '\'' . ',';
}
$str .= ']; ';
if (file_put_contents($path, $str)) {
$this->success('添加成功');
} else {
$this->error('添加失败');
}
}
读取
echo config('配置参数.二级参数');
echo config('配置参数1');
网友评论