Write an array to the configuration file. Why does the & symbol change to & amp; $ config_arr = var_export ($ configdata, true );
$ Config_txt =" File_put_contents ('config. ini. php', $ config_txt );
$ Config_arr is an array with the & symbol in the array value. after writing it to config. ini. php, the & symbol becomes &
Is there a way to keep it unchanged?
Reply to discussion (solution)
This is impossible. it should have been the beginning of your html escape.
$a = array('a' => '&abc');$s = var_export($a, 1);echo $s;
array ( 'a' => '&abc',)
It is possible that the & in your array is an object before writing. Print_r ($ configdata); check the source code.
You have escaped before.
You can use htmlspecialchars_decode to return.
Http://php.net/manual/en/function.htmlspecialchars-decode.php
Before writing, I use print_r to output the result as follows:
The result after the file is written is as follows:
This is the source code:
No html conversion is performed before writing.
This is the source code
After printing it out, check the source code in the browser to see if there is any conversion.
This problem is solved by escaping characters when receiving parameters.
There is another problem:
The configdata array contains the character backslash \. after this sentence
$ Config_arr = var_export ($ configdata, true );
After being written to the configuration file, the backslash becomes \. how can this problem be solved?
#4 display results in html mode
Right-click the source file to view the real data.
Or output before printing.
Mark <br/> echo '<xmp>'; <br/> print_r ($ config_arr ); </p> <p class = "sougouAnswer"> <p class = "yy"> The problem is solved, the character is escaped when parameters are received. <br/> now there is another problem: <br/> The configdata array contains the character backslash \, after this sentence, <br/> $ config_arr = var_export ($ configdata, true ); <br/> after being written to the configuration file, the backslash becomes \. </p> <br/> stripslashes () use this method to go back.