在写入模式下使用fopen()失败 [英] using fopen() in write mode is failing

查看:112
本文介绍了在写入模式下使用fopen()失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我无法在写入模式下对文件使用fopen()。

档案时间与.php文件位于同一目录中,

权限设置为0766.


PHP版本5.2.5

Apache / 2.2.8


代码片段:


$ file =" time";

function updateParseTime($ name){

global $ file;

if(file_exists($ name)&& file_exists($ file)){

if(($ fp = fopen($ file," wb"))){

$ lastmod = filemtime($ name);

if(!) (fwrite($ fp,$ lastmod))){

echo无法更新时间;

}

}

else {

echo" $ file无法打开。 \ n" ;;

}

}

else {

echo" $ name或$ file not not找到。" ;;

}

}


在第4行它没有通过if检查($ fp = fopen。 ..)并且只是

输出$ file无法打开


我错过了什么?

For some reason, I cannot use fopen() on the file in write mode. The
file "time" is in the same directory as the .php file, with
permissions set to 0766.

PHP Version 5.2.5
Apache/2.2.8

code snip in question:

$file = "time";
function updateParseTime($name){
global $file;
if (file_exists($name) && file_exists($file)) {
if(($fp = fopen($file,"wb"))){
$lastmod = filemtime($name);
if(!(fwrite($fp, $lastmod))){
echo "cannot update time";
}
}
else{
echo "$file cannot be opened. \n";
}
}
else{
echo "$name or $file not found.";
}
}

on the 4th line it fails the if check ($fp = fopen...) and just
outputs "$file cannot be opened"

Am I missing something?

推荐答案

file =" time";

函数updateParseTime(
file = "time";
function updateParseTime(


name){

全局
name){
global


文件;

if(file_exists(
file;
if (file_exists(


这篇关于在写入模式下使用fopen()失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆