PHP writes array to file example code_PHP tutorial
WBOY
Release: 2016-07-13 10:44:57
Original
836 people have browsed it
There are many ways to write arrays into files in PHP. For example, if we want to make a cache file, we will convert the PHP array into a file and save it to a .php file. When calling, we can directly call this file.
php writes the array to the file through sequence and desequence. Please see the code
·var_export — used to output or return a string representation of a variable. The difference between it and var_dump() is that var_export() can be used to return structural information about the variable passed to the function, and the representation it returns It is legal PHP code. If "echo $string_process;", you can see the output:
And this is what we want to write to the test_array.php file (minus the php tag);
·The var_dump() function is used to print information about variables. It is only used to "print" and does not return a value. Its prototype is void var_dump(...), let's "var_dump($string_process); ”, you can see the output result:
You can see the output string(86) "...", which once again shows that var_export() returns a string.
http://www.bkjia.com/PHPjc/633068.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633068.htmlTechArticleThere are many ways to write arrays to files in php. For example, if we want to make a cache file, we will use php The array is converted into a file and then saved to a .php file. This file can be called directly when calling. p...
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn