PHP fprintf Function

PHP fprintf write a formatted string to a stream (example: text file or database).

SYNTAX

 

int fprintf ( resource $handle , string $format [, mixed $args [, mixed $… ]] )

 

RETURN VALUE

Returns the length of the string

Example for PHP fprintf Function

<?php
$number = 10;
$str = “Landon”;
$file = fopen(“city.txt”,”w”);
echo fprintf($file,”We live in %u Town %s.”,$number,$str);
?>