PHP - filemtime 函数错误
您好,当我的网站中包含缓存脚本时,我收到此错误。
警告:filemtime() [function.filemtime]: stat failed for index.php in C:\xampp\htdocs\Content\content\cache.php on line 6
这是脚本:
<?php
class datemod{
public $gmtime;
function date($files,$dbtable,$url){
foreach($files as $val){
$mod=date('Y/m/d H:i:s',filemtime($val));
$array[]=$mod;
}
$fmod=max($array);
$result=mysql_query("SELECT DATE_FORMAT(pubdate,'%Y/%m/%d %H:%i:%s') AS pubdate FROM $dbtable WHERE url='$url'");
while($row=@mysql_fetch_array($result,MYSQL_ASSOC)){
$row[]=array('row'=>array_map('htmlspecialchars',$row));
$pubdate=$row['pubdate'];
}
$maxmod=max($fmod,$pubdate);
$this->gmtime=date('D, d M Y H:i:s T',strtotime($maxmod));
}
function cache($gmtime){
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])||isset($_SERVER['HTTP_IF_NONE_MATCH'])){
if($_SERVER['HTTP_IF_MODIFIED_SINCE']==$gmtime){
header('Status:304 Not Modified',true,304);
exit();
}
}
header("Last-Modified:$gmtime");
}
}
?>
我似乎找不到它有什么问题..有什么帮助吗?
Hi i get this error when a cache script is included in my site..
Warning: filemtime() [function.filemtime]:
stat failed for index.php in C:\xampp\htdocs\Content\content\cache.php on line 6
Here is the script:
<?php
class datemod{
public $gmtime;
function date($files,$dbtable,$url){
foreach($files as $val){
$mod=date('Y/m/d H:i:s',filemtime($val));
$array[]=$mod;
}
$fmod=max($array);
$result=mysql_query("SELECT DATE_FORMAT(pubdate,'%Y/%m/%d %H:%i:%s') AS pubdate FROM $dbtable WHERE url='$url'");
while($row=@mysql_fetch_array($result,MYSQL_ASSOC)){
$row[]=array('row'=>array_map('htmlspecialchars',$row));
$pubdate=$row['pubdate'];
}
$maxmod=max($fmod,$pubdate);
$this->gmtime=date('D, d M Y H:i:s T',strtotime($maxmod));
}
function cache($gmtime){
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])||isset($_SERVER['HTTP_IF_NONE_MATCH'])){
if($_SERVER['HTTP_IF_MODIFIED_SINCE']==$gmtime){
header('Status:304 Not Modified',true,304);
exit();
}
}
header("Last-Modified:$gmtime");
}
}
?>
I cant seem to find whats wrong with it.. any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
触发警告是因为当前目录中没有文件
index.php
(可以使用getcwd()
检索)The warning is triggered because there is no file
index.php
in the current dir (can be retrieved usinggetcwd()
)这意味着传递给
filemtime()
的文件不存在,或者程序无权访问其属性。也许可以从显示或记录
$val
开始,看看它是否是预期的。如果一切正常,则检查文件权限,包括路径中每个目录的权限。It means that either file passed to
filemtime()
doesn't exist, or the program doesn't have permission to access its attributes.Maybe begin by displaying or logging
$val
to see if it is what is expected. If all looks well there, then check the file permissions, including of every directory in the path.