傅令江的光影色彩世界
php将数组缓存成文件
2014-8-23 令狐江
<?php
//将数组保存为文件 - 用户读写配置项,保存配置文件
//本脚本自身要有写权限,生成目标文件要有读取和执行权限
 
echo '<pre>'; print_r($_SERVER); //这里使用SERVER代替配置数组
 
$code = var_export($_SERVER, true);
$code = implode("\r", array('<?php', "return {$code};"));
$code = str_replace('  ', "\t", $code);
 
file_put_contents('conf.php', $code);
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容