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

  • SEARCH
  • Home
  • 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 585151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:58:23+00:00 2026-05-13T14:58:23+00:00

I have a config.inc file in a web application that I am building. It

  • 0

I have a config.inc file in a web application that I am building. It contains an array with configuration values for things like the MySQL database, etc. I would like these to be entered by using a simple form, that asks for the server, login/password for the database, etc, then these get written to the configuration file.

Is there a preferred method of doing this? I am not sure how to write to a file, and update an array.

  • 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. Editorial Team
    Editorial Team
    2026-05-13T14:58:23+00:00Added an answer on May 13, 2026 at 2:58 pm

    You just want writing, correct? Is it a serialized array or is it parsed?

    One way to read a config file is parse_ini_file(). I wouldn’t necessarily call it preferred, but it’s a method. You’d still need to write the file.

    Another way would to write a "config.inc.php" and just include it in, to write it you’d just output actual PHP code (e.g. $var = "myval";).

    This is a way you could write a simple "output" function that took an array of configuration values and output them as name=value, assuming $config was an associative array.

    foreach ($config as $name => $value) {
       $output .= $name . '=' . $value . "\n";
    }
    
    if (!file_put_contents($filename, $output)) {
        die("Error writing config file.");
    }
    

    There’s a lot of decent ways to do it. It’s really based on your requirements. Does it need to be in a specific format or do you have leeway?

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

Sidebar

Related Questions

In my ASP.NET application I have a web.config file. In the web.config file I
As many do I have a config.php file in the root of a web
I have referenced a config file that is located in a solution folder. I
I have the following web config file. I am having some difficulty in retrieving
I have a web application that uses a number of WCF Services. I deploy
I have developed a simple application in GWT. After that, I generate war file
I have a subdirectory with a simple web.config <configuration> <system.web> <!--<authorization> <allow roles=admin/> <deny
I have config.time_zone in environment.rb set to UTC, and my mySQL server returns the
I have a Samurize config that shows a CPU usage graph similar to Task
I have an app.config file inside my TestProject, but when I try to read

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.