config.php
--------------------------
return array(
'a' => 1,
'b' => 2,
'c' => 3,
);
?>
getconfig.php
--------------------------
$config = require('config.php');
print_r($config);
?>
大家试一下,会发现$config变量里存储了config.php中的数组, 这就是运用了php可以把文件当作return函数的一种用法。
以上就介绍了PHP读取文件中的数组作为配置文件,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。