PHP set_file_buffer () instance tutorial
Definition and usage
The set_file_buffer () function sets an open file for the buffer size.
The output uses fwrite () normally in the 8 K buffer. Therefore, if two processes write to the same file, each write will be paused before the 8K action and allow others to write to us. If the buffer is 0, the write operation is not buffered (that is, the first write process will be completed before it is allowed, and other processes write ).
This function returns 0 successfully. Otherwise, it returns the EOF.
Syntax
set_file_buffer(file,buffer)
| Parameter |
Description |
| file |
Required. Specifies the open file |
| buffer |
Required. Specifies the buffer size in bytes |
Tips and instructions
Tip: this function is an alias stream_set_write_buffer ().
For example
Create a non-buffered stream:
<?php$file = fopen("test.txt","w");if ($file) { set_file_buffer($file,0); fwrite($file,"Hello World. Testing!"); fclose($file); }?>