function save($data) { //如果缓存目录不存在则创建 if (!$this->is_exist(false)) { file::folder($this->save_dir); } if ($this->ext == 'php') { $data = '<?php' . PHP_EOL . 'return ' . var_export($data, true) . ';'; } if ($this->ext == 'js') { $data = json_encode($data); } if ($this->ext == 'ini') { $data = help::array_ini($data); } if ($this->ext == 'xml') { $data = '<?xml version="1.0" encoding="utf-8"?><data>' . help::data_xml($data) . '</data>'; } if (is_array($data) && $this->ext == 'txt') { $data = serialize($data); } return file_write($this->file_name, $data); }