set_file_buffer()

set_file_buffer() — Alias of stream_set_write_buffer().

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

set_file_buffer() is an alias of stream_set_write_buffer(): same parameters, same return value.

Signature

set_file_buffer(resource $stream, int $size): int

Parameters

ParameterTypeWhat it takes
$streamresourceThe file pointer.
$sizeintThe number of bytes to buffer. If size is 0 then write operations are unbuffered. This ensures that all writes with fwrite() are completed before other processes are allowed to write to that output stream.

Return value

Returns 0 on success, or another value if the request cannot be honored.

Example

A runnable snippet:

$fp = fopen($file, "w"); if ($fp) { if (stream_set_write_buffer($fp, 0) !== 0) { // changing the buffering failed } fwrite($fp, $output); fclose($fp); }

All PHP 8.5 built-in functions

Reference card built from the PHP manual page set_file_buffer() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.