こんにちは、お時間をいただきありがとうございます。次のコードに問題があります。
//reads all the data from $fileName and returns it
private function readFile($fileName)
{
$location = $this->path.$fileName;
try{//try to open file
$file=fopen($location,"r");
}
catch(Exception $e){
return $e;
}
$return = "";//read file contents
while (!feof($file))
{
$return .= fgetc($file);
}
//close file and return result
fclose($file);
return $return;
}
クラスにこの関数がありますが、fopen を呼び出すたびに次の例外がスローされます。
Warning: readfile(messages.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\zdupp\php\textChat.php on line 85
しかし、 $location 変数を確認したところ、問題ありませんでした("../chat/1.2/messages.txt");
ファイルもあります。Cから始まるパスも試しました:
C:/xampp/htdocs/zdupp/chat/1.2/messages.txt
しかし、成功しませんでした。助けていただけませんか?
解決
readFile() と $this->readFile() は別の関数でした。コードは問題ありませんでしたが、呼び出されませんでした。返信ありがとうございます。