$fiele = '../data/conf/watermark.php';//指定要写入的文件 $param = $this->request->param(); $watermark = $param['watermark'];//获取前台传值 $array = "<?php return ['watermark'=>'".$watermark."']//需要写入的值 ?>"; if(file_put_contents($fiele, $array)){//写入文件 $this->success('配置成功', url('')); }else{ $this->success('配置失败', url('')); }