ausheng

thinkphp配置文件动态修改

protected function update_config($new_config, $config_file = '') {
    !is_file($config_file) && $config_file = CONF_PATH . '/config.php';

    if (is_writable($config_file)) {
        $config = require $config_file;

       $config = array_merge($config, $new_config);
       file_put_contents($config_file, "<?php \nreturn " . stripslashes(var_export($config, true)) . ";", LOCK_EX);
        @unlink(RUNTIME_FILE);
        return true;
    } else {
        return false;
    }
}

ausheng

爱生活,爱编程

AUSHENG – BLOG

不要害羞,保持联系。我们喜欢结识有趣的人,结交新朋友。