Why do I need `fclose` after writing to a file in PHP?

前端 未结 7 983
囚心锁ツ
囚心锁ツ 2020-12-29 03:44

Why do I need to finish by using the fclose($handle) function after writing to a file using php? Doesn\'t the program automatically do this when it ends?

7条回答
  •  没有蜡笔的小新
    2020-12-29 04:06

    When a file is opened, a lock is placed on it, preventing other processes from using it. fclose() removes this lock.

    $handle is not an object, just a pointer. So there is no destructor telling it to unlock.

提交回复
热议问题