User Tools

Site Tools


uphp:functions:ini_set

This is an old revision of the document!


ini_set

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Set a value in an INI file

Description

int ini_set ( string $filename, string $section, string $key, mixed $value )

This function writes a configuration key/value pair to an INI file.

If the INI file does not already exist it is created with the given section, key and value. However, if the INI file already exists it is updated only for the specified section, key and value, which preserves any other information, sections, keys or values that might be in the file to begin with.

If the section does not exist it is appended to the end of the file along with the key and value.

If the key does not exist it is added to the section, if it exists, otherwise the section, key and value are appended to the end of the file.

Parameters

$filename: Full path and name of the INI file

$section: Name of the section inside the INI file

$key: Name of the key inside the section

$value: The value to write (string, int or float)

Return Values

Integer: 1 on success or 0 on failure

Example

<?
  $fn="/ini_set_example.ini";
  ini_set($fn,"network","address1","90.0.0.1");
  ini_set($fn,"general","enabled",1);
  ini_set($fn,"general","connected",0);
  /* ... get connected ... */
  ini_set($fn,"general","connected",1);
?>

The INI file will contain:

[network]
address1=90.0.0.1
[general]
enabled=1
connected=1

See Also

ini_get() - Get a value from an INI file

ini_get_array() - Get a group of parameters from an INI file as an array

ini_put_array() - Write a group of parameters to an INI file from an array

uphp/functions/ini_set.1494544295.txt.gz · Last modified: 2021/09/13 05:56 (external edit)