Php writes the array to a file, and reads many open-source projects. configuration information of some projects is generally written in the file, and some are written into the constant of the configuration file, some are written to the array. However, those are relatively complex and the array is not studied in depth. I have roughly read the constant. it is generally complicated to modify. First, you need to write the array in php to the file and then read it.
I have seen many open-source projects. configuration information of some projects is generally written in files,
Some are constants written to the configuration file, and some are written to arrays.
However, those are relatively complex and the array is not studied in depth. I have roughly read the constant,
Generally, modification is complicated. First, you need to read all the configuration files,
Then, replace the content through regular expression matching, and then write the content to the file,
The method I used below is relatively simple and easy. I will post the code.
If (isset ($ _ POST ['sub ']) {$ cfg = array ('Contact' = >$ _ POST ['Contact ']); // save the data to the array file_put_contents ('. /data/contact. cache ', serialize ($ cfg); // serialize the array and write it to contact. in the cache, $ this-> redirect ('other/contact'); // jump} else {$ fp = fopen ('. /data/contact. cache ', 'r'); // read $ cf = unserialize (fread ($ fp, filesize ('. /data/contact. cache '); // deserialize and assign $ this-> assign ('cfg', $ cf ); // send to the foreground template $ this-> display ('other/contact ');}