我看到一种写法:
class ET {
public static $config = array();
public static function writeConfig($values)
{
if (file_exists($file = PATH_CONFIG."/config.php")) include $file;
if (!isset($config) or !is_array($config)) $config = array();
$config = array_merge($config, $values);
self::$config = array_merge(self::$config, $values);
$contents = "<?php\n";
foreach ($config as $k => $v) $contents .= '$config["'.$k.'"] = '.var_export($v, true).";\n";
$contents .= "\n// Last updated by: ".ET::$session->user["username"]." (".ET::$session->ip.") @ ".date("r")."\n?>";
file_put_contents($file, $contents);
}
}
ET::writeConfig(array("esoTalk.skin" => $skin));
想知道有什么好的轮子可用吗?
1
vibbow 2015-01-13 18:39:37 +08:00
config.php:
<?php //config in json $config = file_get_contents('config.php') $config = substr($config, 8); $config = json_decode($config, true); |
2
Actrace 2015-01-14 10:57:46 +08:00
楼主这是用生命在水贴啊,不怕被各路大神骂死嘛....
|