0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PHP Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given in

Posted at
修正前
$fp = fopen('test.txt', 'w');
fclose($fp);

PHP Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given in ........................

修正後
$fp = fopen('test.txt', 'w');
if ($fp) {
    fclose($fp);
}

ファイルが正常に開かれたか確認する:
fclose()を試みる前に、ファイルが正常に開かれたことを確認してください。ファイルのオープンに失敗すると、fopen()がfalseを返す可能性があり、それが問題の原因となります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?