In PHP we provide a function var_export he can directly put the PHP code into a file OH.
The code is as follows |
Copy Code |
Var_export ($times, true); Cannot write to file after not added $fp = fopen (' aa.txt ', ' w+ '); Fwrite ($fp, Var_export ($times, true)); Fclose ($FP); |
Method Two
Using Serializ and Unserialize functions
The code is as follows |
Copy Code |
if (Isset ($_post[' Sub ')) { $cfg = Array (' Contact ' =>$_post[' contact '); Storing the data in an array File_put_contents ('./data/contact.cache ', serialize ($cfg)); After serializing the array, write to the Contact.cache, $this->redirect (' other/contact ');//Jump } else{ $fp = fopen ('./data/contact.cache ', ' r ');//Read $CF = Unserialize (Fread ($fp, FileSize ('./data/contact.cache '));//deserialization, and assignment $this->assign (' cfg ', $CF);//Send to foreground template $this->display (' other/contact '); } |
http://www.bkjia.com/PHPjc/629652.html www.bkjia.com true http://www.bkjia.com/PHPjc/629652.html techarticle in PHP we provide a function var_export he can directly put the PHP code into a file OH. The code below copies the code Var_export ($times, true);