PHP vfprintf Function

What is vfprintf Function?


This function is used to write a formatted string to a stream.



In the above syntax "stream" specifies where to write the string,"format" specifes the formatting string to be used "%%", "%b", "%c", "%d", "%e", "%u", "%f", "%F", "%o", "%s", "%x", "%X", "argarray" specifies an array with arguments to be inserted at % sign.

Example :

$str = "Hi";
$number = 200;
$file = fopen("test.txt","w");
echo vfprintf($file,"%s my mark is %u",array($str,$number));

Result in the browser:


Result in "test.txt".

Hi my mark is 200

In the above PHP example the output is written into the file "test.txt", the string is written based on the formatting strings.

PHP Topics

Ask Questions

Ask Question