Basic PHP example: Use a regular expression to modify the configuration information.
Working principle of various php files:
The following is the code pulling time:
<? Php // configuration file information define ("HOST", "localhost"); // HOST name define ("USER", "rootaaaa"); // USER name define ("PASSWORD ", "root123456"); // password define ("DBNAME", "mydb"); // Database NameDbconfig. php <? Php // modify the configuration file // 1. read the configuration file information $ info = file_get_contents ("dbconfig. php "); // 2. traverse POST and replace foreach with regular expressions in configuration file information ($ _ POST as $ k => $ v) {$ info = preg_replace ("/define \ (\" {$ k }\",\"(. *?) \ "\)/", "Define (\" {$ k} \ ", \" {$ v} \ ")", $ info);} // 3. write the replaced information back to the configuration file file_put_contents ("dbconfig. php ", $ info); echo"