0

I am building up a simple PHP script to get all my site css/js files combined.

What I would like to do now is checking for the most recent built css or js file in the "cache" folder.

So... some function like:

function getLastFile('js'){
   return the js file name
}

function getLastFile('css'){
   return the css file name
}

I've found out solutions on the net on how to check for the last file in some folder... but how can I exactly check the last by a specific extension?

4

2 回答 2

1

您可以使用glob函数。

获取 js 文件,使用glob('cache/*.js');and 获取 cssglob(cache/*.css); 并且可以使用filetime获取最新修改的文​​件。

参考这个问题。

于 2013-10-06T03:02:44.877 回答
0

如果你的意思是最后一个 most recent built

//get the last-modified-date of this very file
$lastModifiedTime=filemtime($Cachedfile);

或者最好看一下smartoptimizer代码,稍微看一下它的源代码,你肯定会明白的

于 2013-10-06T03:01:48.267 回答