Jump to content

Recommended Posts

I have a small configuration file which PHP must be able to read from and write to.

 

Do you recommend using JSON, or using a PHP ini file along with parse_ini_file()?  Please explain your reasoning.

 

If JSON, how do you recommend saving and retrieving the data?  For instance, an array or object?

 

If an ini file, how do you recommend saving the file?

 

Thanks

Edited by NotionCommotion

I assume a database is out of the question?

 

JSON is easier to write out again. Associative arrays and objects are the same thing when exported so it only matters how you want to deal with them in the code.

Why all the mystery in a simple ini file? Why not a simple text file with a defined format? You want the user to maintain it, so how is it going to get to the server? Email? Ftp? ok. So now it's on the server. Why does it have to be endoded. Why not just like the php.ini file format?

So there's that question:

 

Does the file need to be (should it be) human-readable and editable? INIs are easier for that. And at only four values you can just use some simple scheme like ginerjm's simple text file.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.