(PHP 4, PHP 5, PHP 7, PHP 8) parse_ini_file — Parse a configuration file Descriptionparse_ini_file(string The structure of the ini file is the same as the php.ini's. Parametersfilename The filename of the ini file being parsed. If a relative path is used, it is evaluated relative to the current working directory, then the include_path. process_sections By setting the scanner_mode Can either be
As of PHP 5.6.1 can also be specified as Return Values The settings are returned as an associative array on success, and ExamplesExample #1 Contents of sample.ini ; This is a sample configuration file ; Comments start with ';', as in php.ini [first_section] one = 1 five = 5 animal = BIRD [second_section] path = "/usr/local/bin" URL = "http://www.example.com/~username" [third_section] phpversion[] = "5.0" phpversion[] = "5.1" phpversion[] = "5.2" phpversion[] = "5.3" urls[svn] = "http://svn.php.net" urls[git] = "http://git.php.net" Example #2 parse_ini_file() example
Constants (but not "magic constants" like
('BIRD', 'Dodo bird');// Parse without sections The above example will output something similar to: Array ( [one] => 1 [five] => 5 [animal] => Dodo bird [path] => /usr/local/bin [URL] => http://www.example.com/~username [phpversion] => Array ( [0] => 5.0 [1] => 5.1 [2] => 5.2 [3] => 5.3 ) [urls] => Array ( [svn] => http://svn.php.net [git] => http://git.php.net ) ) Array ( [first_section] => Array ( [one] => 1 [five] => 5 [animal] => Dodo bird ) [second_section] => Array ( [path] => /usr/local/bin [URL] => http://www.example.com/~username ) [third_section] => Array ( [phpversion] => Array ( [0] => 5.0 [1] => 5.1 [2] => 5.2 [3] => 5.3 ) [urls] => Array ( [svn] => http://svn.php.net [git] => http://git.php.net ) ) ) Example #3 parse_ini_file() parsing a php.ini file
The above example will output something similar to: (parsed) magic_quotes_gpc = Yes (loaded) magic_quotes_gpc = Yes Example #4 value interpolation In addition to evaluating constants, certain characters have special meaning in an ini value. Additionally, environment variables and previously defined values may be read using ; | is used for bitwise OR three = 2|3 ; & is used for bitwise AND four = 6&5 ; ^ is used for bitwise XOR five = 3^6 ; ~ is used for bitwise negate negative_two = ~1 ; () is used for grouping seven = (8|7)&(6|5) ; \ is used to escape a value. newline_is = "\\n" ; results in the string "\n", not a newline character. with quotes = "She said \"Exactly my point\"." ; Results in a string with quote marks in it. path = ${PATH} also_five = ${five} The above example will output something similar to: (parsed) magic_quotes_gpc = Yes (loaded) magic_quotes_gpc = Yes Notes
pd at frozen-bits dot de ¶ 12 years ago
;?> uramihsayibok, gmail, com ¶ 11 years ago
(parse_ini_string(' michel ¶ 9 years ago
Anonymous ¶ 19 years ago
jeremygiberson at gmail dot com ¶ 13 years ago
?> fbeyer at clickhand dot de ¶ 19 years ago
$pizzas[$user_pizza] & PIZZA_ONION) {
grant at rootcentral dot org ¶ 9 years ago
bob at kludgebox dot com ¶ 20 years ago
Anonymous ¶ 12 years ago
EOT; pBakhuis at googles mail dot com (gmail) ¶ 13 years ago
$array as $arrayValue ) Bill Brown - macnimble.com ¶ 13 years ago
Rekam ¶ 8 years ago
?> Adam ¶ 15 years ago
flacroix897 at hotmail dot com ¶ 13 years ago
mark at hostcobalt dot com ¶ 15 years ago
simon dot riget at gmail dot com ¶ 9 years ago
dschnepper at box dot com ¶ 6 years ago
Justin Hall ¶ 15 years ago
"<pre>"; www.onphp5.com ¶ 14 years ago
mauder[remove] at [remove]gmail[remove] dot com ¶ 16 years ago
geggert at web dot de ¶ 12 years ago
kieran dot huggins at rogers dot com ¶ 19 years ago
juampii_4 at hotmail dot com ¶ 14 years ago
printini($file, $sector, $var) mgcummings at yahoo dot SPAMNO dot com ¶ 8 years ago
Rolf ¶ 11 years ago
info () gaj ! design ¶ 5 years ago
YAPs ¶ 6 years ago
info () gaj ! design ¶ 5 years ago
jbricci at ya-right dot com ¶ 6 years ago
forcestudios.square7.de ¶ 12 years ago
; goulven.ch AT gmail DOT com ¶ 14 years ago
?>
jerikojerk ¶ 11 years ago
dimk at pisem dot net ¶ 17 years ago
$properties = array();
Johannes Schmidt ¶ 10 years ago
Mauro Gabriel Titimoli ¶ 12 years ago
$CONF_EXT_RELATION = array( yicktan ¶ 9 years ago
= "config.php"; freamer89 at gmail dot com ¶ 12 years ago
?>
yarco dot w at gmail dot com ¶ 15 years ago
arnapou ¶ 14 years ago
Yhann ¶ 2 years ago
Rubn Martnez ¶ 4 years ago
= array();// ...$files = scandir($directory); Alex - webitoria.com ¶ 11 years ago
nbraczek at bsds dot de ¶ 16 years ago
dshearin at excite dot com ¶ 19 years ago
The php. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. php. ini file is the configuration file. ini file: Whenever we install PHP, we can locate the configuration file inside the PHP folder. If using xampp, we can find the configuration file in one or many versions, inside the path '\xampp\php'. If you're using WAMP for your local WordPress installation, you can easily find the location of php. ini by right-clicking on the program icon and navigating to PHP > php. ini. That's it. |