parse_ini_file
pathinfo
Filesystem Functions
PHP Manual

# parse_ini_string

(PHP 5 >= 5.3.0)

parse_ini_string — Parse a configuration string

### Descripción

array parse_ini_string ( string `$ini` [, bool `$process_sections`= false [, int `$scanner_mode`= INI_SCANNER_NORMAL ]] )

parse_ini_string() returns the settings in string `ini` in an associative array.

The structure of the ini string is the same as the php.ini's.

### Lista de parámetros

`ini`

  The contents of the ini file being parsed.

`process_sections`

  By setting the `process_sections` parameter to `TRUE`, you get a multidimensional array, with the section names and settings included. The default for `process_sections` is `FALSE`

`scanner_mode`

  Can either be `INI_SCANNER_NORMAL` (default) or `INI_SCANNER_RAW`. If `INI_SCANNER_RAW` is supplied, then option values will not be parsed.

### Valores retornados

The settings are returned as an associative array on success, and `FALSE` on failure.

### Ejemplos

Example #1 parse_ini_file() parsing a php.ini file

`<?php
// A simple function used for comparing the results below
function yesno($expression)
{
return($expression ? 'Yes' : 'No');
}
// Get the path to php.ini using the php_ini_loaded_file()
// function available as of PHP 5.2.4
$ini_path = php_ini_loaded_file();
// Parse php.ini
$ini = parse_ini_file($ini_path);
// Print and compare the values, note that using get_cfg_var()
// will give the same results for parsed and loaded here
echo '(parsed) magic_quotes_gpc = ' . yesno($ini['magic_quotes_gpc']) . PHP_EOL;
echo '(loaded) magic_quotes_gpc = ' . yesno(get_cfg_var('magic_quotes_gpc')) . PHP_EOL;
?>`

El resultado del ejemplo seria algo similar a:

    (parsed) magic_quotes_gpc = Yes
    (loaded) magic_quotes_gpc = Yes

### Notes

> Note: There are reserved words which must not be used as keys for ini files. These include: null, yes, no, true, false, on, off, none. Values null, no and false results in "", yes and true results in "1". Characters {}|&~![()^" must not be used anywhere in the key and have a special meaning in the value.

### Ver también

- parse_ini_file() - Procesar un archivo de configuración

parse_ini_file
pathinfo
Filesystem Functions
PHP Manual