Read and Update Config file (INI File) in PHP

To parse / read INI file in PHP is very simple, there is a default function called parse_ini_file() which will read and return all the values as an array. 

To update or edit the INI file through PHP is little difficult, you cannot simply update the exact value in the INI, instead you have to re-write the entire INI file.

First, let’s look at an example INI file:


The below script will read the INI file and print it on the page.


Let’s jump to the script which will read as well write the INI file.


Read the comments in the above file to learn how the script works.

See the DEMO or Download the script to use it in your project.

demo download



Add a Comment

Your email address will not be published. Required fields are marked *