Function name: stream_set_write_buffer()
Applicable version: PHP 4 >= 4.3.0, PHP 5, PHP 7
Function description: stream_set_write_buffer() function is used to set the write buffer size of the stream.
Syntax: bool stream_set_write_buffer ( resource $stream , int $buffer )
parameter:
Return value: Return true if the buffer size is successfully set, otherwise return false.
Example:
// 打开一个文件流$stream = fopen('example.txt', 'w'); // 设置写缓冲为8192 字节if (stream_set_write_buffer($stream, 8192)) { echo '写缓冲大小设置成功!'; } else { echo '写缓冲大小设置失败!'; } // 关闭文件流fclose($stream);
In the example above, we first use the fopen() function to open a file stream, and then use the stream_set_write_buffer() function to set the write buffer size to 8192 bytes. If the setting is successful, the output is "Write buffer size setting is successful!", otherwise the output is "Write buffer size setting is failed!". Finally, we use the fclose() function to close the file stream.
Notice:
ini_set('default_socket_send_buffer', 8192);