fprintf()

It writes a formatted string to a specified output stream

Example

<?php
$fp = fopen(“test.txt”,”w”);
echo fprintf($fp,”%s”,”phpcode”);
?>

Output

7