PHP set_file_buffer() Function

❮ PHP Filesystem Reference

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);
}
?>


Definition and Usage

The set_file_buffer() function specifies the number of bytes to buffer on the given file.

Output using fwrite() is normally buffered at 8K. So, if two processes writes to the same file, each will write up to 8K before pausing, and allow the other to write. If buffer is 0, write operations are unbuffered (meaning that the first write process will be completed before allowing other processes to write).

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

Syntax

set_file_buffer(file, buffer)

Parameter Values

Parameter Description
file Required. Specifies a file pointer
buffer Required. Specifies the number of bytes to buffer


Technical Details

Return Value: 0 on success, another value if request failed
PHP Version: 4.3+

❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.