PHP Tutorial - PHP set_file_buffer() Function






Definition

The set_file_buffer() function sets the buffer size of an open file.

This function is an alias of stream_set_write_buffer().

Syntax

PHP set_file_buffer() Function has the following syntax.

set_file_buffer(file,buffer)

Parameter

ParameterIs RequiredDescription
fileRequired.Open file
bufferRequired.Buffer size in bytes

Return

This function returns 0 on success, otherwise it returns EOF.





Example

Create an unbuffered stream:


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