abstract class PublicAction extends Action {
/**
* 公共类
*/
public function _initialize(){
$classname = get_class($this);
$this->model = M(substr($classname,0,-6));
$this->cache();
$this->SaveSetting();
}
//获取要清楚的目录和目录所在的绝对路径
public function cache(){
//RUNTIME_FILE常量是入口文件中配置的runtimefile的路径及文件名;
if(file_exists(RUNTIME_FILE)){
unli
}
//光删除runtime_file还不够,要清空一下Cache文件夹中的文件;代码如下:
$cachedir=RUNTIME_PATH."/Cache/"; //Cache文件的路径;
if ($dh = opendir($cachedir)) {//打开Cache文件夹;
while (($file = readdir($dh)) !== false) { //遍历Cache目录,
unli
}
closedir($dh);
}
}
function SaveSetting(){
//setting.config.php文件的路径,通过settingfile_path来设定;
$setfile = './admin'.C('settingfile_path');
$a=C('setting'); //将默认配置参数的内容赋值给$a;
$b=array(
'tel' => $_POST['tel'],
'web' => $_POST['web'],
);
//这里将新的参数值,通过后台的表单提交过来;
$c=array_merge($a,$b) ;
$settingstr="<?php \n return array(\n'Setting' =>array(\n";
foreach($c as $key=>$v){
$settingstr.= "\t'".$key."'=>'".$v."',\n";
}
$settingstr.="),\n);\n?>\n";
file_put_contents($setfile,$settingstr); //通过file_put_contents保存setting.config.php文件;
}
}
?>
Cache文件夹就没被删掉,setting.config.php配置文件里依然是空的,print_r($setfile);显示的是./admin,c怎么没起作用呢
最佳答案