IniCommented

Parses standard INI files, maintaining comments within the file.

In contrast to IniFile, the IniCommented container parses the ini file manually using regular expressions and is slower. If you only read the file, using IniFile is more appropriate since it's faster.

Available Options
Option Data Type Default value Description
linebreak string \n Character(s) used to separate lines from each other.

Writing a .desktop file

<?php
require_once 'Config.php';

$conf = new Config();
$root $conf->getRoot();
//note: inicommented uses ";" as comment indicator while the desktop entry spec
// says that it has to be "#" - so no comments for .desktop files
$entry $root->createSection('Desktop Entry');
$entry->createDirective('Version''1.0');
$entry->createDirective('Type''Link');
$entry->createDirective('URL''http://pear.php.net/');
$entry->createDirective('Name''go to pear.php.net');
$entry->createDirective('Icon''gnome-fs-bookmark');
$r $conf->writeConfig(
    
'/home/cweiske/Desktop/pear.php.net.desktop',
    
'inicommented',
    
//windows newlines are not required in desktop files;
    // they just serve as example how to use container options
    
array('linebreak' => "\r\n")
);
if (
PEAR::isError($r)) {
    echo 
$r->getMessage() . "\n";
}
?>

Generated file

[Desktop Entry]
Version = 1.0
Type = Link
URL = http://pear.php.net/
Name = go to pear.php.net
Icon = gnome-fs-bookmark
GenericConf (Previous) IniFile (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.