原生php读取ini配置用parse_ini_file()函数修改配置项应该用什么函数呢?
parse_ini_file()
作曲家需要 piwik/ini
修改配置没有原生支持,可以自己实现或者使用别人的轮子
我是搬运工
https://packagist.org/package...
<?php require 'vendor/autoload.php'; use WriteiniFile\WriteiniFile; $data = [ 'fruit' => ['orange' => '100g', 'fraise' => '10g'], 'legume' => ['haricot' => '20g', 'oignon' => '100g'], 'jus' => ['orange' => '1L', 'pomme' => '1,5L', 'pamplemousse' => '0,5L'], ]; // demo create ini file $a = new WriteiniFile('file.ini'); $a->create($data); $a->add([ 'music' => ['rap' => true, 'rock' => false] ]); $a->rm([ 'jus' => ['pomme' => '1,5L'] ]); $a->update([ 'fruit' => ['orange' => '200g'] // 100g to 200g ]); $a->write(); echo '<pre>'.file_get_contents('file.ini').'</pre>'; /* output file.ini [fruit] orange = "200g" fraise = "10g" [legume] haricot = "20g" oignon = "100g" [jus] orange = "1L" pamplemousse = "0,5L" [music] rap = 1 rock = 0 */ $b = new WriteiniFile('file.ini'); $b->erase(); $b->write();
作曲家需要 piwik/ini
修改配置没有原生支持,可以自己实现或者使用别人的轮子
我是搬运工