读取和修改操作array 配置文件的方法

配置文件如

return  array('''key'=>"value");

读取就和简单

直接file_get_content()

读取出来回写,比较麻烦,可以使用下面的方法:

        $page_config['widgets']['_widget_284']['options'] = array_merge($page_config['widgets']['_widget_284']['options'], $options);
        
        $page_config_file = ROOT_PATH . '/data/page_config/default.index.config.php';
        $php_data = "<?php\n\nreturn " . var_export($page_config, true) . ";\n\n?>";
        
        file_put_contents($page_config_file, $php_data, LOCK_EX);
原文地址:https://www.cnblogs.com/linksgo2011/p/3054342.html