The set_file_buffer() function sets the buffer size for open files.
Use the fwrite() function to output the results. The buffer size is usually 8K. Therefore, if two processes were to write to the same file, each file would only be able to write up to 8K in size at a time, and other processes would be allowed to write to it. If buffer is 0, then the write operation will not be buffered (this means: other processes will not be allowed to write until the first writing process has completed).
This function returns 0 if successful, otherwise returns EOF.
set_file_buffer(file,buffer)
parameter | describe |
---|---|
file | Required. Specifies the file to open. |
buffer | Required. Specifies the buffer size, in bytes. |
Tip: This function is an alias of stream_set_write_buffer().
Create an unbuffered stream:
<?php$file = fopen("test.txt","w");if ($file) { set_file_buffer($file,0); fwrite($file,"Hello World. Testing!"); fclose($ file); }?>