Search code examples
phparraysvariablesadmin

Changing website variables in file


I'm building a CMS that has an admin panel. I have an array that looks like this:

$GLOBALS = array(
    "site_title" => "cms",
    "site_addr" => "localhost",
    "site_logo" => "favicon.png",
);

Now as if the user wanted to change the title for example, what is the best way to do it? Should I change the value in the array or should I store that information in the database (But that would then slow the page, right?)? What would you do? Thanks


Solution

  • I recommend you store the variables in the database and when the specific user logs into your website, he can extract those values into an array very easily. The best way to INSERT and EXTRACT data from a database would be, in my opinion, using MySQL (PDO).

    Regarding your question on slowing the page: databases are designed to execute queries efficiently. Almost all dynamic websites have a bunch of code in the back end being processed every time you enter it so I wouldn't say the speed difference would cause you any problems.

    Let me know if that answered your question!