Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring settings, to edit later, in PHP
    text
    copied!<p>I am writing a PHP application that will have the ability to edit settings through a web interface. I didn't mean for the user (and actually, it will only be <strong>admins</strong>) to be able to load the file up in a text editor, but rather, they make a change using a form, and that will change the settings file (and <em>do other things as well</em>).</p> <p>At this stage in the development, settings are stored in a PHP file, for example:</p> <pre>define ('UPLOAD_DIR','uploads/'); define ('DISPLAY_NUM',true); $names = array('a' => 'b','c'=>'d','e'=>'f');</pre> <p>However, parsing arrays (and they get more complicated (i.e multilevel nested) than the above), doesn't seem so fun. And because specific settings can be added and removed, reading the entire file, and then writing out all the settings again, doesn't seem fun either. </p> <p>What are the advantages and disadvantages to using the following formats? (And any others that I missed out):</p> <ul> <li>Custom XML</li> <li>INI (able to use parse_ini_file)</li> </ul> <p>(Using a database <em>is not</em> suitable due to the requirements for the project. I understand in many situations a database would be prefered, just not in this case.)</p> <p>If you were unable to use a database, and had to store settings that could be edited using a web interface, what would you do? </p> <p>(Note: This is a different question to <a href="https://stackoverflow.com/questions/798654/how-to-store-configurations-for-php-app-xml-or-ini-or-db">this one</a>, where settings can't be changed, it's PHP file all the way. And yes, the setup does currently write out a PHP file with the correct settings.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload