简体   繁体   中英

Save database connection details

I'm creating a setup script for a project, where a form would ask the user for database connection details (such as host, username and password), and it should store these in a file which the main system can use in the future.

How could this be accomplished - by generating an .ini file, or by using PHP to edit another PHP file?

Check This link

     $my_file = 'db.ini';
        $handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file);
/*Writing*/
        $data = 'This is the data';
        fwrite($handle, $data);
/*Reading*/
$handle = fopen($my_file, 'r');
$data = fread($handle,filesize($my_file));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM