- /**
- * 讀取或設定緩衝
- *
- * @access public
- * @param string $name 緩衝名稱
- * @param mixed $value 緩衝內容, null刪除緩衝
- * @param string $path 緩衝路徑
- * @return mixed
- */
- function cache($name, $value = , $path = )
- {
- return false; //調試階段, 不進行緩衝
- $path = empty($path) ? ROOT_PATH . /Runtime/Data/ : $path;
- $file = $path . $name . .php;
- if (empty($value)) {
- //緩衝不存在
- if (!is_file($file)) {
- return false;
- }
- // 刪除緩衝
- if (is_null($value)) {
- unlink($file);
- return true;
- }
- $data = include $file;
- return $data;
- }
- $value = var_export($value, true);
- $value = "";
- return file_put_contents($file, $value);
- }
- //函數調用
- cache(name, array(a, b, c)); //寫入緩衝 name為緩衝名稱, 後面那個數組是緩衝的內容
- cache(name); //讀取緩衝
- cache(name, null); //刪除緩衝
- ?>
http://www.bkjia.com/PHPjc/486194.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486194.htmlTechArticle?php /** * 讀取或設定緩衝 * * @access public * @param string $name 緩衝名稱 * @param mixed $value 緩衝內容, null刪除緩衝 * @param string $path 緩衝路徑 * @re...