I am writing a PHP library and to increase its portability and robustness I would like to be able to read the php.ini file to access the installation settings.
Is there a simple way to do this or do I need to do this the hard way and write code to parse this myself?
Thanks
The ini_set() function allows you to change system attributes that affect the way your script is executed. Changes only affect the current script, and will revert back when the script ends. To use ini_set() , pass it the value you want to change as its first parameter, and the new value to use as its second parameter.
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'. Note: Other versions of this file are php. ini-development and 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.
I doubt that you need all of the php.ini file. For specific values, why not use ini_get()
? For example, to get the maximum post size, you can simply use:
$maxPostSize = ini_get('post_max_size');
PHP has a nice support for INI files. Along with the php_ini_loaded_file()
you can get the details of current ini file.
<?php
// get path to the ini file
$inipath = php_ini_loaded_file();
// Parse with sections
$ini_array = parse_ini_file($inipath , true);
print_r($ini_array);
?>
http://php.net/manual/en/function.parse-ini-file.php
http://php.net/manual/en/function.php-ini-loaded-file.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With