Ask PHP fflush The problem, not working

Source: Internet
Author: User
Tags flushes
Have you ever used fflushFunction

The official explanation is that:
Flushes the output to a file
This function forces a write of all buffered output to the resource pointed to by the file handle.

This means that the write cache of the file is forcibly released to the file pointer.
http://php.net/manual/en/function.fflush.php

But I found that the content was written to the file immediately after Fwrite was executed. Do not need to fflush, also do not need fclose, to this question feel very puzzled, fflush actually has provided what function.

Code:


  
   

Reply content:

Have you ever used a fflush function

The official explanation is that:
Flushes the output to a file
This function forces a write of all buffered output to the resource pointed to by the file handle.

This means that the write cache of the file is forcibly released to the file pointer.
http://php.net/manual/en/function.fflush.php

But I found that the content was written to the file immediately after Fwrite was executed. Do not need to fflush, also do not need fclose, to this question feel very puzzled, fflush actually has provided what function.

Code:


  
    

Refer you to a method Stream_set_write_ Buffer , the default buffer_size is 8 K , that is, fwrite If the amount of data written at one time is greater than Buffer_ A size of , which splits the write. This situation needs to be considered when working with the same file in a multi-process, usually fflush is not very useful, but it does not matter, after all, fopen can also open other file resources.

  • Related Article

    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.