function getCategorys () { global $mysql, $cfg_cache_category; $cache = SYSPATH . "/data/cache/categorys.php"; if (!file_exists($cache) || (time() - filemtime($cache)) > $cfg_cache_category) { $categorys = array(); $arrays = $mysql->getArrays("SELECT id, fid, name, url FROM my_category"); if (!empty($arrays)) { foreach ($arrays as $v) { $categorys[$v['id']] = $v; } unset($arrays); unset($v); } $fp = fopen($cache, 'w'); if ($fp) { fwrite($fp, serialize($categorys)); fclose($fp); } else { httpError(500, "写入栏目缓存文件失败"); } unset($categorys); } $fp = fopen($cache, 'r'); if ($fp) { $array = unserialize(fread($fp, filesize($cache))); return $array; unset($array); } else { httpError(500, "读取栏目缓存文件失败"); } }
以上就是MyNews 调用栏目信息(缓存方式)的内容,更多相关内容请关注PHP中文网(www.php.cn)!