Fastest way to store easily editable config data in PHP?

后端 未结 7 1390
借酒劲吻你
借酒劲吻你 2020-12-01 03:46

What is the fastest way to store config data in PHP so that it is easily changeable (via PHP)? First I thought about having config.php file, but I can\'t edit it on fly with

7条回答
  •  日久生厌
    2020-12-01 04:17

    Whilst it's most likely overkill for what you're after, but what I tend to do is store the config data in a database using a PHP class to control the changes to the name/value pairs within. (i.e.: There's no direct DB access from outside this class.)

    When a call is made to the PHP config class to change a value, this then writes out a standard PHP include file with all of various values defined on it.

    As such, there's no load time performance hit when reading the config data and all config data can be changed within the database via a CMS module.

提交回复
热议问题