0

我注意到安装 PHP 脚本之一的目录有非常大的 error_log 文件,几乎有 1GB 大小,大部分错误是由第 478 行和第 479 行的编码生成的。error_log 文件中的错误示例如下:

PHP Warning:  filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for /home/khan/public_html/folder/ZBall.jar in /home/khan/public_html/folder/index.php on line 478
PHP Warning:  filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for /home/khan/public_html/folder/ZBall.jar in /home/khan/public_html/folder/index.php on line 479

我有以下编码,第 477 到 484 行

foreach ($mp3s as $gftkey => $gftrow) {
   $ftimes[$gftkey] = array(filemtime($thecurrentdir.$gftrow),$gftrow);
   $ftimes2[$gftkey] = filemtime($thecurrentdir.$gftrow);
 }
 array_multisort($ftimes2,SORT_DESC,$ftimes);
 foreach ($ftimes as $readd) {
   $newmp3s[] = $readd[1];
 }

请帮助我。

谢谢.. :)

4

3 回答 3

2

stat failed错误表明该文件/home/khan/public_html/games/ZBall.jar不存在,或者由于权限错误而无法读取。确保文件存在于 PHP 正在查找的位置,因为这似乎是问题的最相似原因。

由于它来自数组$mp3s,因此请确保该数组包含存在的文件的名称,如果不存在则对其进行修改。

于 2011-12-30T19:37:00.920 回答
1

在对它做某事之前询问文件。检查我的编辑:

<?php
foreach ($mp3s as $gftkey => $gftrow) {
   if (file_exists($thecurrentdir.$gftrow)) {
     $ftimes[$gftkey] = array(filemtime($thecurrentdir.$gftrow),$gftrow);
     $ftimes2[$gftkey] = filemtime($thecurrentdir.$gftrow);
   }
 }
 array_multisort($ftimes2,SORT_DESC,$ftimes);
 foreach ($ftimes as $readd) {
   $newmp3s[] = $readd[1];
 }
于 2011-12-30T19:39:15.520 回答
0

PHP.net 网站上有一个函数可以消除 Windows 上关于filemtime

function GetCorrectMTime($filePath) { 

$time = filemtime($filePath); 

$isDST = (date('I', $time) == 1); 
$systemDST = (date('I') == 1); 

$adjustment = 0; 

if($isDST == false && $systemDST == true) 
    $adjustment = 3600; 

else if($isDST == true && $systemDST == false) 
    $adjustment = -3600; 

else 
    $adjustment = 0; 

return ($time + $adjustment); 
}

资源:http://php.net/manual/tr/function.filemtime.php#100692

于 2015-08-23T19:41:15.977 回答