sagephp / ini
INI 文件操作。支持节和注释
dev-master
2013-11-15 21:30 UTC
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-24 00:40:32 UTC
README
此组件正确地读取和写入 INI 文件。与 PHP 函数不同,值不会被自动转换(例如 Off 到 0 等)
特性
与 INI 文件一起使用时预期的特性。
它还保留了注释,包括行注释和值后面的注释,因此
; line comment
key = value ; bla bla
都将被保留
安装
composer.phar require sage-php/ini dev-master
使用
use SagePHP\Component\Parser\Ini\Ini as IniParser;
$ini = new IniParser(file_get_contents('/path/to/file'));
if ($ini->hasSection('php')) {
echo 'php section found';
}
if ($ini->hasKey('version', 'php')) {
echo 'php version:' . $ini-get('version', 'php');
}
$ini->set($key = 'bar', $value = 'zed', $section = 'section', $comment = 'just a test');
$ini->remove($key = 'bar', $section = 'section');
file_put_contents('/path/to/file', $ini);