W3Schools.com

PHP set_file_buffer() Function


PHP Filesystem Reference Complete PHP Filesystem Reference

Definition and Usage

The set_file_buffer() function sets the buffer size of an open 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).

This function returns 0 on success, otherwise it returns 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().


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);
  }
?>


PHP Filesystem Reference Complete PHP Filesystem Reference

W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE