PHP 警告:filemtime() [function.filemtime]

发布于 2024-12-24 02:24:00 字数 906 浏览 1 评论 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];
 }

请帮助我。

谢谢.. :)

I've noticed that the directory on which one of the PHP script is installed have very large error_log file almost of 1GB size, mostly the errors are generated by coding on line 478 and 479.. example of the error from error_log file is below:

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

I have the following coding, line 477 to 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];
 }

Please help me on this.

Thanks.. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情深已缘浅 2024-12-31 02:24:00

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

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

The stat failed error would indicate that the file /home/khan/public_html/games/ZBall.jar either doesn't exist, or can't be read due to a permission error. Make sure the file exists in the place PHP is looking, as that seems like the most like cause of the problem.

Since it comes from the array $mp3s, make sure that array contains names of files that exist and modify it if not.

渡你暖光 2024-12-31 02:24:00

在使用该文件进行操作之前询问该文件。检查我的编辑:

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

ask for the file before doing something with it. checm my edit:

<?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];
 }
稍尽春風 2024-12-31 02:24:00

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

There is a function on PHP.net site which removes a bug on Windows about 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); 
}

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文