★ wanayoo — archive 1999 http://www.php.net/manual/ro/function.parse-ini-string.phpNouvelle recherche | Portail wanayoo
PHP
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

pathinfo> <parse_ini_file
Last updated: Fri, 14 Aug 2009

view this page in

parse_ini_string

(PHP 5 >= 5.3.0)

parse_ini_stringParse a configuration string

Descrierea

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.

Parametri

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.

Valorile întroarse

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

Note

Notă: 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.

Vedeţi de asemenea



add a note add a note User Contributed Notes
parse_ini_string
aldo at mschat dot net
01-Aug-2009 10:28
If you want to use something like this on a PHP version below that of PHP 5.3, you can emulate it roughly by doing something like this:

<?php
if(!function_exists('parse_ini_string'))
{
  function
parse_ini_string($ini, $process_sections = false, $scanner_mode = null)
  {
   
# Generate a temporary file.
   
$tempname = tempnam('/tmp', 'ini');
   
$fp = fopen($tempname, 'w');
   
fwrite($fp, $ini);
   
$ini = parse_ini_file($tempname, !empty($process_sections));
   
fclose($fp);
    @
unlink($tempname);
    return
$ini;
  }
}
?>

May not be the most efficient way (I suppose you could do some regex stuff instead...) but it certainly works!

pathinfo> <parse_ini_file
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites