PHP parse_ini_string() Function

PHP parse_ini_string Function


Define :

In this tutorial we have to learned about PHP parse_ini_string() Function .The  parse_ini_string() Function is inbuilt function in php.This function is parses a configuration (ini) string and returns the settings as an associative array.

Some reserved words used not be used as keys for ini files like null, yes, no, true, false, on, off, none. Values null, off, no and false result in "", and values on, yes and true result in "1", unless INI_SCANNER_TYPED mode is used.Characters ?{}|&~![()^" must not be used anywhere in the key and have a special meaning in the value.

Syntax

  parse_ini_string(iniprocess_sectionsscanner_mode)

Parameter 
Parameter Description
ini Required. Specifies the ini file to parse
process_sections Optional. If set to TRUE, it returns is a multidimensional array with section names and settings included. Default is FALSE
scanner_mode

Optional. Can be one of the following values:

  • INI_SCANNER_NORMAL (default)
  • INI_SCANNER_RAW (means option values will not be parsed)
  • INI_SCANNER_TYPED (means that boolean, null and integer types are preserved when possible. "true", "on", "yes" are converted to TRUE. "false", "off", "no", "none" are converted to FALSE. "null" is converted to NULL. Numeric strings are converted to integer type if possible)

Given below example  shows how to use the parse_ini_string() function to parse a configuration (ini) string. 

Output :