Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

set_file_buffer()

Example

Create a stream with no buffering.

<?php
$file = fopen(“test.txt”,“w”);
if ($file) {
  set_file_buffer($file,0);
  fwrite($file,“Hello World. Testing!”);
  fclose($file);
}
?>

Definition and Usage

The set_file_buffer() function sets the number of bytes to buffer for a given file.

By default, output with fwrite() is buffered at 8K. Thus, if two processes write to the same file, each can write up to 8K before pausing to allow the other to write. Setting the buffer to 0 makes write operations unbuffered, so one process will complete its write before another process can write.

 

Tip: This function is an alias of stream_set_write_buffer().

Syntax

set_file_buffer(filebuffer)

Parameter Values

Parameter

Description

file

Required. Specifies a file handle.

buffer

Required. Specifies the number of bytes to use for buffering.

Technical Details

 

Return Value:

Returns 0 on success; returns a different value if the request fails.

PHP Version:

4.3+