美文网首页
修改独立配置文件

修改独立配置文件

作者: 小进我是爸爸 | 来源:发表于2020-04-03 15:26 被阅读0次
    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');
    
    

    相关文章

      网友评论

          本文标题:修改独立配置文件

          本文链接:https://www.haomeiwen.com/subject/gvnhphtx.html