php能不能动态显示html5,php – 是否可以动态生成html5缓存清单?
解決方法:
很確定,但是讓我告訴你:讓HTML5離線內容與JavaScript applicationCache.update()等完美配合.人.如果你是新手,有點麻煩.最終一切都有效……記錄在案!但是CAVEAT LECTOR ……
無論如何,這是一個(希望)自我解釋的PHP專用示例,您需要一個.htaccess文件.這將告訴您的服務器將cache.manifest解釋為PHP代碼(因為沒有.php擴展名,所以需要).
您的.htaccss文件,以防您使用FCGI Wrapper:
AddType text/cache-manifest .manifest
SetHandler fcgid-script
FcgidWrapper /folder/to/your/php-fcgi-starter .manifest
Options +ExecCGI
你的.htaccess文件,以防你使用apache php模塊(大多數情況下,這將是默認情況):
AddType text/cache-manifest .manifest
SetHandler application/x-httpd-php
你的cache.manifest文件:
// only cache files in the following folders (avoids other stuff like "app/")
$folders = array('js', 'lib', 'views', 'styles');
$files = array('index.html');
// recursive function
function append_filelist(&$files, $folder) {
if ($dh = opendir($folder)) {
while (($file = readdir($dh)) !== false) {
if ( ! in_array($file, array('.', '..', '.svn')) &&
(substr($file, -4) != ".swp")) {
if (is_dir($folder."/".$file))
append_filelist($files, $folder."/".$file);
else
//$files[] = $folder."/".$file."?hash=".md5_file($folder."/".$file);
$files[] = $folder."/".$file;
} // if
} // while
} // if
}
// init
foreach ($folders as $folder)
if (is_dir($folder))
append_filelist($files, $folder);
// generate output
$body = "CACHE MANIFEST\n\nCACHE:\n";
foreach ($files as $file)
$body .= $file."\n";
$body .= "\nNETWORK:\n*\n";
// render output (the 'Content-length' header avoids the automatic creation of a 'Transfer-Encoding: chunked' header)
header('Content-type: text/cache-manifest');
header('Content-length: '.strlen($body));
echo $body;
祝好運!
標簽:php,html5,dynamic,cache-manifest
來源: https://codeday.me/bug/20190722/1507786.html
總結
以上是生活随笔為你收集整理的php能不能动态显示html5,php – 是否可以动态生成html5缓存清单?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab system object
- 下一篇: 动态规划算法php,php算法学习之动态