0

Hello! I'm creating a larger scale application in PHP and i'm using a .ini file to store some configuration for the user, quite easy to fetch data with the parse_ini_file function (returns array) but how would I write to a ini file, or the most convienient way to do so. That is needed because I am created a installer wizard type of thing and an admin panel, so it would be nice to write to the configuration file. Thanks for any help!

3
Contributors
7
Replies
11
Views
4 Years
Discussion Span
Last Post by NardCake
0

@NardCake

Hello! I'm creating a larger scale application in PHP and i'm using a .ini file to store some configuration for the user, quite easy to fetch data with the parse_ini_file function (returns array) but how would I write to a ini file, or the most convienient way to do so. That is needed because I am created a installer wizard type of thing and an admin panel, so it would be nice to write to the configuration file. Thanks for any help!

The question you ask is a bit broad or very general. What you do want to do?

Here is a list of directives and the parse_ini_file function:

http://php.net/manual/en/ini.list.php

http://php.net/manual/en/function.parse-ini-file.php

It provide a examples that you can used.

If you have a code that you are working on.

It would be nice if you can post what you have so far, so we can have a better idea what you want to do.

Edited by LastMitch: grammer

0

Basically, I have an application the reads a pre-existing "config.ini" file. I want to write a 'installer' for my application so the user can easily insert data into the fields and it will write or edit the configuration file (config.ini). Say for example this is my ini file.

admin_email=admin@example.com
admin_username=ADMIN 
admin_password=password 

Now in my installation it would ask for those fields, and I want to write or edit the file so it contains what the user specified, so for example it would now be

admin_email=mynewemail@example.com
admin_username=MyNewUsername
admin_password=MyNewPassWord

Hopefully that clears it up. And thanks I will browse through those links and try to find something. Thanks!
--Edit--
And just to make this clear this has nothing to do with php.ini.

Edited by NardCake: Clearing up some possible confusion.

0

And just to make this clear this has nothing to do with php.ini.

The ini file is part of PHP. Unless you didn't explain it very clearly on what you want to do with the ini file.

The parse_ini_file() function can help you update/create configuration files by writing the whole config.ini file. Read/parse the existing settings into a php array. Then it will set any of the array elements with values/new values, then write the whole config.ini file based on that array of settings.

I hope that make sense. If not then can you explain little more in detail. I know you provide a small code but it would be easier if you can explain more.

0

Alright thanks for the info, I will look through all of this interesting information. Thanks again! (both of you)

Edited by NardCake

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.