国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

php獲取一個文件夾的mtime的程序

2024-05-04 21:50:10
字體:
供稿:網(wǎng)友

php很容易獲取到一個文件夾的mtime,可以使用filemtime函數(shù)。但文件夾的filemtime由于linux的原因。文件修改時,只會影響他當(dāng)前的文件夾mtime變化。并不會繼續(xù)影響文件夾上層的文件夾。所以可能跟真正想得到的文件夾的最后修改時間不同。

看linux機(jī)器上的效果如下, 可以看到y(tǒng)oyoTmp的mtime小于yoyoTmp/test的mtime。

  1. [root@localhost test]# ls -ld --full-time /yoyoTmp/ 
  2. drwxr-xr-x. 4 root root 34 2015-12-01 21:09:47.526804049 +0800 /yoyoTmp/ 
  3. [root@localhost test]# ls -ld --full-time /yoyoTmp/test 
  4. drwxr-xr-x. 2 root root 20 2015-12-01 21:15:22.266131826 +0800 /yoyoTmp/test 

也可使用stat 文件夾命令查看mtime之類信息,google得知一個phper實(shí)現(xiàn)了如下 原文鏈接:

  1. function dirmtime($directory) { 
  2.     // 1. An array to hold the files. 
  3.     $last_modified_time = 0; 
  4.  
  5.     // 2. Getting a handler to the specified directory 
  6.     $handler = opendir($directory); 
  7.  
  8.     // 3. Looping through every content of the directory 
  9.     while ($file = readdir($handler)) { 
  10.         // 3.1 Checking if $file is not a directory 
  11.         if(is_file($directory.DIRECTORY_SEPARATOR.$file)){ 
  12.             $files[] = $directory.DIRECTORY_SEPARATOR.$file
  13.             $filemtime = filemtime($directory.DIRECTORY_SEPARATOR.$file); 
  14.             if($filemtime>$last_modified_time) { 
  15.                 $last_modified_time = $filemtime
  16.             } 
  17.     } 
  18.  
  19.     // 4. Closing the handle 
  20.     closedir($handler); 
  21.  
  22.     // 5. Returning the last modified time 
  23.     return $last_modified_time
  24.  
  25. Example 
  26.  
  27. This example demonstrates how to find the last modified time of the directory, where the working PHP script file resides, and print the result to the screen. 
  28.  
  29.  PHP. Print the Last Modified Time of Current Directory  ? 
  30. $directory = dirname(__FILE__); 
  31.  
  32. $dir_last_modified_time = dirmtime($directory); 
  33.  
  34. echo date('d M Y h:i:s'$dir_last_modified_time); 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 剑川县| 深水埗区| 广南县| 黔西| 弥渡县| 乌什县| 海南省| 宝清县| 聂荣县| 沂南县| 渭南市| 青龙| 岳普湖县| 石阡县| 襄城县| 本溪市| 房产| 旅游| 延津县| 阜宁县| 铜川市| 平江县| 桐乡市| 隆昌县| 乌拉特中旗| 横峰县| 鸡泽县| 钟祥市| 玛曲县| 玉田县| 平度市| 蒙城县| 蓬莱市| 库伦旗| 扎鲁特旗| 大荔县| 乌拉特前旗| 皮山县| 深州市| 东台市| 浏阳市|