• PHP Video Tutorials

PHP - Function fputs()


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

Syntax

fputs(file,string,length)

This function is binary-safe means that both binary data such as images and character data can be written using this function.

Example

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

Output

24
php_function_reference.htm
Advertisements