当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > set_file_buffer() 函数

PHP
PHP 安全邮件
MySQL 介绍
连接 MySQL
创建 MySQL
MySQL 插入记录
MySQL 选择记录
MySQL Where
MySQL Order By
MySQL 记录更新
MySQL 删除记录
PHP ODBC
XML Expat Parser
XML SimpleXML
PHP 数组参考
PHP Calendar
PHP Date
PHP Directory
PHP Filesystem
PHP FTP
PHP HTTP

PHP 中的 set_file_buffer() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 425 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The set_file_buffer() function sets the buffer size of an open file.
set_file_buffer()函数的作用是:为一个打开的文件设置缓冲[buffer]的空间大小。

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).
使用fwrite()函数输出结果,缓冲的大小通常为8k,因此,如果要将两个进程写入同一个文件,那么每个文件最多只能写进8k大小;如果buffer=0,那么将不对操作程序进行缓冲(这意味着:只有在第一个进程全部写入完成之后,才能写入其他进程)。

This function returns 0 on success, otherwise it returns EOF.
如果函数成功执行将返回0;否则将返回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 Notes
提示

Tip: This function is an alias of stream_set_write_buffer().
提示:set_file_buffer()函数和stream_set_write_buffer()函数的功能相同。


Example
案例

Create an unbuffered stream:
建立一个“非缓冲文本流”:

<?php
$file = fopen("test.txt","w");
if ($file) { set_file_buffer($file,0); fwrite($file,"Hello World. Testing!"); fclose($file); }
?>

评论 (0) All

登陆 | 还没注册?