Home  >  Article  >  Backend Development  >  php怎么设置全局变量

php怎么设置全局变量

WBOY
WBOYOriginal
2016-06-13 12:25:461555browse

php如何设置全局变量
RT,我把一些信息放在了txt文档里,然后每次调用这个php页面时就读出来存进一个数组里,我想知道怎么让这个数组缓存到内存里,每次判断如果不存在然后再去读取,在的话就直接用。这个可行吗?新手
------解决思路----------------------
你把数组写成一个配置文件php,不要使用txt,然后include调用就可以了。
读文件也不会很慢的。如果你要写入内存,可以使用memcache保存。

例如:
config.php

<br /><?php<br />return array(<br />	'name' => 'fdipzone'<br />);<br />?><br />


demo.php
<br /><?php<br />$config = include('config.php');<br />print_r($config);<br />?><br />

Statement:
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