PHP实现 CSS文件添加版本号;JS添加版本号。
<?php/**CSS、JS设置版本号*/function autoVer($url){$ver = date("Y-m-d H:i:s",filemtime($_SERVER['DOCUMENT_ROOT'].$url)); //filemtime()读取文件修改的最新时间,返回时间戳。echo $url.'?v='.$ver;}?><!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><!--<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" /><link href="favicon.ico" rel="Bookmark" type="image/x-icon" />--><meta name="Generator" content="EditPlus®"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Description" content=""><title>Document</title><link href="<?php autoVer('/css/css.css'); ?>" rel="stylesheet" type="text/css" > //取得版本号<script src="<?php autoVer('/js/js.js'); ?>"></script> //取得版本号</link></head><body><h1>Hello,world!</h1></body></html>