: This article mainly introduces PHP to read arrays from files as configuration files. For more information about PHP tutorials, see. You may have seen many open-source products. most of their configuration files are stored in a separate file, and this file contains only one array, in fact, here we use a PHP tips to include files and assign values to a variable. this variable has an array of the entire configuration. I will give you an example:
Config. php
--------------------------
Return array (
'A' => 1,
'B' => 2,
'C' => 3,
);
?>
Getconfig. php
--------------------------
$ Config = require ('config. php ');
Print_r ($ config );
?>
If you try it, you will find that the $ config variable stores the array in config. php. this is a usage in which php can treat the file as a return function.
The above introduces PHP to read the array in the file as the configuration file, including the content, hope to be helpful to friends interested in PHP tutorials.