Basic PHP example: use a regular expression to modify the configuration information. Basic PHP example: use a regular expression to modify the configuration information. In this example, the regular expression is used for various working principles of php: The following is the code pulling Time :? Php configuration file information define (HOST, loca PHP Basic example: use a regular expression to modify the configuration information, sample regular expression
Working Principle of various php files:
The following is the code pulling Time:
Dbconfig. php $ 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" modified successfully! "; Echo" back ";Doupdate. php "Host", "USER" => "USER", "PASSWORD" => "PASSWORD", "DBNAME" => "database name"); // 1. read the configuration file information $ info = file_get_contents ("dbconfig. php "); // Set dbconfig. read the information in the PHP file and assign it to the info variable // 2. use regular expressions to parse the configuration file information preg_match_all ("/define \(\"(. *?) \",\"(.*?) \ "\)/", $ Info, $ a); // resolve the information in info to a variable for storage // 3. traverse the parsed information and output it to the modified form echo "edit configuration file"; echo "";Edit. php
Various php Working Principle: The following is the code pulling Time :? Php // define ("HOST", "loca...