Create an unbuffered stream:
<?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 specifies the number of bytes to buffer on the given file.
Output using fwrite() is normally buffered at 8K. So, if two processes writes to the same file, each will write up to 8K before pausing, and allow the other to write. If buffer is 0, write operations are unbuffered (meaning that the first write process will be completed before allowing other processes to write).
Tip: This function is an alias of stream_set_write_buffer().
set_file_buffer(
file,
buffer)
Parameter | Description |
---|---|
file | Required. Specifies a file pointer |
buffer | Required. Specifies the number of bytes to buffer |
Return Value: | 0 on success, another value if request failed |
---|---|
PHP Version: | 4.3+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!