PHP - Application config file stored as - ini,php,sql,cached,php class,JSON,php array?

后端 未结 10 818
死守一世寂寞
死守一世寂寞 2020-12-13 14:15

I am trying to decide on the best way to store my applications configuration settings. There are so many options.

The majority of applications I have seen have used

10条回答
  •  死守一世寂寞
    2020-12-13 14:59

    In my view good solution would be ini files.

    I don't prefer config file using arrays/variables for storing settings; here is why:

    What if a user accidently re-named your setting variable?
    What if a variable with similar name is defined elsewhere too by the user?
    Variables in config file may be overwritten some where deep in the script or even included files.
    and possibly more problems....

    I like to use ini file for setting of my php apps. Here is why:

    It is section based
    It is easier
    You can set values by friendly names
    You don't have to worry about variables being overwritten because there are no ones.
    No conflict of variables of course. It allows more flexibility in specifying the types of values.

    Note: You need to use parse_ini_file function to read ini files.

提交回复
热议问题