簡體   English   中英

PHP警告:filemtime()[ <a href='function.filemtime'>function.filemtime</a> ]

[英]PHP Warning: filemtime() [<a href='function.filemtime'>function.filemtime</a>]

我注意到,其中安裝了一個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];
 }

請幫我。

謝謝.. :)

stat failedstat failed錯誤將表明/home/khan/public_html/games/ZBall.jar文件不存在,或者由於權限錯誤而無法讀取。 確保該文件存在於PHP所查找的位置,因為這似乎是問題的最可能原因。

由於它來自數組$mp3s ,因此請確保該數組包含存在的文件名,如果不存在,請對其進行修改。

在處理文件之前先詢問文件。 檢查我的編輯:

<?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];
 }

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 : http://php.net/manual/tr/function.filemtime.php#100692

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM