English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP set_file_buffer() Function Usage and Example

PHP Filesystem Reference Manual

The set_file_buffer() function sets the buffer size of the opened file. The output from the fwrite() function is usually buffered8K to buffer. Therefore, if two processes write to the same file, each process can write at most8K, and allows other processes to write. If the buffer is 0, write operations are not buffered, meaning the first writing process can complete before allowing other processes to write. This function can return 0 on success, otherwise it returns EOF.

Syntax

set_file_buffer(file, buffer)

This function is an alias of the stream_set_write_buffer() function.

Online Example

<?php
   $file = fopen("/PhpProject/sample.txt", "w");
   if ($file) {
      set_file_buffer($file, 0);
      fwrite($file, "Hello World!");
      
      fclose($file);
   }
?>

PHP Filesystem Reference Manual