在/Application/Common/Common创建function.php,然后添加以下代码:

<?php
/**
 * [writeArr 写入配置文件方法]
 * @param  [type] $arr      [要写入的数据]
 * @param  [type] $filename [文件路径]
 * @return [type]           [description]
 */
function writeArr($arr, $filename) {
    return file_put_contents($filename, "<?php \r\n return " . var_export($arr, true) . ";");
}
?>

  

在保存配置时:
// 写入配置文件
public function setConfig(){
    $file = CONF_PATH.'/setConfig.php';
    if(writeArr($_POST,$file)){
      $this->success('修改成功');
    }else{
      $this->error('修改失败');
    }
}

  

 




 

相关文章:

  • 2022-02-08
  • 2021-06-04
  • 2022-12-23
  • 2021-12-01
  • 2021-12-31
  • 2022-02-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2021-09-28
  • 2021-08-06
  • 2021-10-10
相关资源
相似解决方案