PHP parse_ini_string() Function

PHP pathinfo() Function
PHP parse_ini_file() Function

In this article, you will learn how to read and parse the configuration string in PHP. The configuration string in PHP is determined by the .ini extension. The parse_ini_file() function in PHP parses a configuration (ini) string and returns the settings.

Remember that the PARSE_INI_STRING function only reads the user-defined configuration in files. It does not access the php.ini file.

what is the syntax of the PARSE_INI_STRING function in php?

parse_ini_string(ini, process_sections, scanner_mode)
ParameterDescription
iniRequired. Specifies the ini file to parse
process_sectionsOptional. If set to TRUE, it returns is a multidimensional array with section names and settings included. Default is FALSE
scanner_modeOptional. 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)
PHP PARSE_INI_STRING() method

examples of the PARSE_INI_STRING function

Example 1. In this example, we Parse an ini string.

$ini = '
[names]
me = "Robert"
you = "Peter"

[urls]
first = "http://www.example.com"
second = "https://www.w3schools.com"
';

print_r(parse_ini_string($ini));
PHP pathinfo() Function
PHP parse_ini_file() Function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top