亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

時間是怎么寫入文件里面的


public function __construct() {

$this->_dir = dirname(__FILE__) . '/files/';

}

public function cacheData($key, $value = '', $cacheTime = 0) {

$filename = $this->_dir ?. $key . self::EXT;


if($value !== '') { // 將value值寫入緩存

if(is_null($value)) {

return @unlink($filename);

}

$dir = dirname($filename);

if(!is_dir($dir)) {

mkdir($dir, 0777);

}


$cacheTime = sprintf('%011d', $cacheTime);

return file_put_contents($filename,$cacheTime . json_encode($value));

}


if(!is_file($filename)) {

return FALSE;

}?

$contents = file_get_contents($filename);

$cacheTime = (int)substr($contents, 0 ,11);

$value = substr($contents, 11);

if($cacheTime !=0 && ($cacheTime + filemtime($filename) < time())) {

unlink($filename);

return FALSE;

}

return json_decode($value, true);

}


正在回答

1 回答

return file_put_contents($filename,$cacheTime . json_encode($value)); 時間和json數據一起拼裝插入到文件中去的

0 回復 有任何疑惑可以回復我~
#1

PHP程序媛2016 提問者

非常感謝!
2017-01-24 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
PHP開發APP接口
  • 參與學習       79159    人
  • 解答問題       608    個

APP通信接口技術,不得不掌握的法寶,學完之后你會受益良多

進入課程

時間是怎么寫入文件里面的

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號