English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and Examples of PHP fputs() Function

PHP Filesystem Reference Manual

The fputs() function can write to an open file. This function can stop at the end of the file or at the specified length (whichever comes first). It can return the number of bytes written on success, or FALSE on failure, and it is an alias for the fwrite() function.

Syntax

fputs(file,string,length)

This function is binary safe, which means binary data (such as images and character data) can be written using this function.

Online Example

<?php
   $file = fopen("sample.txt", "w");
   echo fputs($file, "Hello w3codebox!!!!");
   fclose($file);
?>

Output Result

24

PHP Filesystem Reference Manual