php 写入缓存文件、读取缓存文件的函数代码
网络编程
一、写结果缓存文件
/** * 写结果缓存文件 * * @params string $cache_name * @params string $caches * * @return */ function write_static_cache($cache_name, $caches) { if ((DEBUG_MODE & 2) == 2) { return false; } $cache_file_path = ROOT_PATH . '/temp/static_caches/' . $cache_name . '.php'; $content = "<?phprn"; $content .= "$data = " . var_export($caches, true) . ";rn"; $content .= "?>"; file_put_contents($cache_file_path, $content, LOCK_EX); }
二、读结果缓存文件
/** * 读结果缓存文件 * * @params string $cache_name * * @return array $data */ function read_static_cache($cache_name) { if ((DEBUG_MODE & 2) == 2) { return false; } static $result = array(); if (!empty($result[$cache_name])) { return $result[$cache_name]; } $cache_file_path = ROOT_PATH . '/temp/static_caches/' . $cache_name . '.php'; if (file_exists($cache_file_path)) { include_once($cache_file_path); $result[$cache_name] = $data; return $result[$cache_name]; } else { return false; } }
以上就是php 写入缓存文件、读取缓存文件内容的函数代码,需要的朋友可以参考一下。
PHP中遍历二维数组_以不同形式的输出操作实例
如下所示:bodyphp//定义二维索引数组$arr=array(array("101","李军","男","1976-02-20","95033"),array("103","陆君","男","1974-06-03","95031"),array("105","匡明","男","1975-10-02","95
yii2行为的方法如何注入到组件类中详解
前言当了解了行为属性的注入逻辑后,方法的注入对于我们来说就很简单了。逻辑一样。只不过此刻我们不再调用__get方法,而是一个用于方法的__call方
php 实现收藏功能的示例代码
整理文档,搜刮出一个php实现收藏功能的示例代码,稍微整理精简一下做下分享。HTML:aclass="x"id="{$photo.id}"uid="{$Think.session.uid}"status="{$collect_pic}"href="javasc
编辑:一起学习网
标签:缓存,文件,方法,数组,代码