Latest web development tutorials

PHP set_file_buffer () function

PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual

Definition and Usage

set_file_buffer () function to set the buffer size to open the file.

Use fwrite () function of the output buffer size is usually 8K. So, if you want two processes write to the same file, each file can only be written to a maximum size of 8K, and allow other processes to write. If buffer is 0 then write operations will not be buffered (this means: Only after the first write process completed, to allow other processes to write).

If successful, the function returns 0, otherwise it returns EOF.

grammar

set_file_buffer(file,buffer)

参数 描述
file 必需。规定打开的文件。
buffer 必需。规定缓冲大小,以字节计。


Tips and Notes

Tip: This function is stream_set_write_buffer () alias.


Examples

Create unbuffered streams:

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


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual