filetimeとdateを使用したクエリ文字列自動生成サンプル

ブラウザのソースを表示でクエリ文字列が追加されていることが確認できます。

<link href="https://iwb.jp/s/syntaxhighlighter.css<?php ft('/home/iwb/iwb.jp/public_html/s/syntaxhighlighter.css'); ?>" rel="stylesheet">
↓
<link href="https://iwb.jp/s/syntaxhighlighter.css?2020-09-06_20-51-03" rel="stylesheet">
function ft($file) {
  date_default_timezone_set('Asia/Tokyo');
  echo '?' . date('Y-m-d_H-i-s', filemtime($file));
}

元記事を表示する