$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('')); }