How to generate database configuration information files such as config. php

Source: Internet
Author: User
How to generate config. I just learned php from a database configuration file such as PHP. after I write a PHP file for creating a database and creating a form, I want to enter the database address, database username, and database password, create a config. how should I write php files stored in it for database operations? The following shows how to generate a database configuration file, such as config. php, for the user input data created in the form.
I just learned PHP and wrote a PHP code for creating a database and creating a form. I want to create a config with the database address, database username, database password, and created database name entered by the user. how should I write php files stored in it for database operations?
The following code retrieves the user input data in the form to create a database:
PHP code
  
  


------ Solution --------------------
$ Fp = fopen ('config. php', 'W + ');
$ Config = "configure: \ r \ n ";
$ Config. = '$ DB [\ 'address \'] = '. $ sqladdress. "\ r \ n ";
//... Something like this
Fwrite ($ fp, $ config );
Fclose ($ fp );

Then, when reading the configuration file:
Include 'config. php ';
Mysql_connect ($ DB ['address'],...)
------ Solution --------------------
Just put it in the database...

Put the file in the same way. you can simply put the json or csv format into the file. next time, you can easily parse the file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.