filemtime无法读取文件修改时间

时间:2012-08-03 05:12:46

标签: php filemtime

这是我的代码:

 date_default_timezone_set('Europe/Baku');
        $dh =opendir('C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\css');
        $full_path='C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\css';
        $way=array();

        while ($file = readdir($dh)):

         array_push($way,$full_path.$file);
         endwhile;
        closedir($dh);
        echo '<br>';
        for ($t=2;$t<=6;$t++){
       echo "<br> $way[$t] : " . filetype($way[$t]) . "\nCreate Date: " . date("F d Y                       H:i:s ", filemtime((string)$way[$t]) );   

        }


echo '<br>'.date ("F d Y H:i:s.", filemtime('C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\css\blank.gif'));

        ?>

这就是它的回应:

C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\cssblank.gif : Create Date: January 01 1970 00:00:00 C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\cssiepngfix.htc : Create Date: January 01 1970 00:00:00 C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\csswelcome.css : Create Date: January 01 1970 00:00:00 C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\csswelcome_ie6.css : Create Date: January 01 1970 00:00:00 : Create Date: January 01 1970 00:00:00 July 04 2012 16:13:34.

我认为filemtime无法读取修改时间而不知道原因。 请帮帮我。

1 个答案:

答案 0 :(得分:1)

-$full_path='C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\css';
+$full_path='C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\css\';

你在full_path变量中丢失了反斜杠。 所以,你得错文件的完整路径:

'C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\csswelcome.css'

而不是

'C:\Program Files (x86)\Zend\Apache2\htdocs\upload\extjs-4.1.1\welcome\css\welcome.css'