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

PHP
PHP Libxml
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Mail
用PHP5的DirectoryIterators递归扫描目录
PHP 阻止SQL注入式攻击
PHP5面向对象 - 基础 - 类和对象
PHP5面向对象 - 基础 - 类的属性( public )
PHP5面向对象 - 基础 - 类的属性( private )
PHP5面向对象 - 基础 - 方法
PHP5面向对象 - 基础 - 对象的比较
php5面向对象 - 基础 - 构造函数
php5面向对象 - 基础 - 析构函数
用PHP控制用户的浏览器 - ob*函数的使用
PHP PDO 学习笔记

PHP 中的 set_file_buffer() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 426 ::
收藏到网摘: 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

登陆 | 还没注册?