Php: How to Close opened files-php Tutorial

Source: Internet
Author: User
Php: how to disable an opened file
This article introduces how to close opened files in php programming. For more information, see.

In php, after opening a file for related operations, you need to close the file handle in time to avoid occupying resources for a long time.

Php closes a file

In php programming, it is a good habit to close a file in time after it is used up.

Php functions or methods for disabling files

To close a file in php, you need to use the fclose function.

The following is an example of closing a file for your reference.

Code:

     

Code description: the fclose function requires a file handle to be closed. In the above example, we set the variable "$ ourFileHandle" to the file handle returned by the fopen function.

After the initial operation, the opened file testfile.txt is closed, and then the operation such as reading or appending the file content will be invalid. The preceding operations can be continued only when the access file is opened again.

This article describes how to close files in php. I hope it will be helpful to you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.