Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 155923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:14:29+00:00 2026-05-11T10:14:29+00:00

I need to store a bunch of configuration information in PHP. I have considered

  • 0

I need to store a bunch of configuration information in PHP.

I have considered the following….

// Doesn't seem right. $mysqlPass = 'password';   // Seems slightly better. $config = array(      'mysql_pass' => 'password' );  // Seems dangerous having this data accessible by anything. but it can't be // changed via this method. define('MYSQL_PASSWORD', 'password');   // Don't know if this is such a good idea. class Config {     const static MYSQL_PASSWORD = 'password'; }      

This is all I have thought of so far. I intend to import this configuration information into my application with require /config.inc.php.

What works for you with regard to storing configuration data, and what are best practices concerning this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:14:29+00:00Added an answer on May 11, 2026 at 10:14 am

    I’ve always gone with option #2 and just ensure that no one but the owner has ANY sort of access to it. It’s the most popular method among PHP applications like Joomla, vBulletin, Gallery, and numerous others.

    First method is too messy to me (readability) and the third is WAY too dangerous to do. I’ve never thought about the Class method, so someone else can provide their input on that one. But I guess it’s fine so long as the right access is used on the class’ usage.


    Example..

    define('EXAMPLE1', 'test1'); // scenario 1 $example2 = 'test2'; // scenario 2  function DealWithUserInput($input) {    return eval($input); } 

    Now this example of code is really dumb, but just an example. Consider what could be returned by the function depending on which scenario the user could try to use in their input.

    Scenario 2 would only cause an issue if you made it a global within the function. Otherwise it’s out of scope and unreachable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have id values for products that I need store. Right now they are
I need to store a bunch of variables that need to be accessed globally
new to F# i need to store a bunch of lists of objects according
I'm going to need to store a whole bunch of encrypted files. Groups of
Ive got a large bunch of objects (potentially 1000's) which I need to store
I'm using PHP and Graphicsmagick and I have a bunch of users uploading batches
I need to store a bunch of email addresses each having a label (primary
I need to store a bunch of Image SRC attribute values in an array.
Using rails 3.1, ruby 1.92. I have a bunch of products in a store:
I have a situation where I temporarily need to save a bunch of settings

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.