?
$config_file="路徑";if(file_exists($config_file)){$configs=include $config_file;}else {$configs=array();}$configs=array_merge($configs,$data);$result = file_put_contents($config_file, "<?php\treturn " . var_export($configs, true) . ";");
此方法與上一篇http://www.cnblogs.com/qinmei/p/6903333.html最后的結果都一樣
? var_export:輸出或返回一個變量的字符串表示
gentoo這么更新配置文件、 此函數返回關于傳遞給該函數的變量的結構信息,它和 var_dump() 類似,不同的是其返回的表示是合法的 PHP 代碼。
可以通過將函數的第二個參數設置為 TRUE
,從而返回變量的表示。