Create a stream with no buffering.
<?php $file = fopen(“test.txt”,“w”); if ($file) { set_file_buffer($file,0); fwrite($file,“Hello World. Testing!”); fclose($file); } ?> |
The set_file_buffer() function sets the number of bytes to buffer for a given file.
By default, output with fwrite() is buffered at 8K. Thus, if two processes write to the same file, each can write up to 8K before pausing to allow the other to write. Setting the buffer to 0 makes write operations unbuffered, so one process will complete its write before another process can write.
Tip: This function is an alias of stream_set_write_buffer().
set_file_buffer(file, buffer) |
Parameter |
Description |
file |
Required. Specifies a file handle. |
buffer |
Required. Specifies the number of bytes to use for buffering. |
Return Value: |
Returns 0 on success; returns a different value if the request fails. |
PHP Version: |
4.3+ |