VOOZH about

URL: https://www.geeksforgeeks.org/php/php-vfprintf-function/

⇱ PHP vfprintf() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP vfprintf() Function

Last Updated : 25 Aug, 2023

The vfprintf() function is an inbuilt function in PHP that is used to write formatted information to a stream, such as a file or the output screen.

Syntax:

vfprintf(resource $stream, string $format, array $values): 

Parameters: This function accepts three parameters that are described below.

  • $stream: This parameter tells you where you write the string. It could be a file or a standard output like a screen.
  • $format: This is a template that shows how you want to arrange your data. It contains placeholders (like %d, %s, etc.) that represent where your actual data will go.
  • $values: This array holds the actual data that will be inserted into the placeholders of the format string.

Return Values: The vfprintf() function returns the count of the character written to the screen. It will return an integer type

Program 1: The following program demonstrates the vfprintf() function.


Output
Successfully wrote 22 characters to the file.

Program 2: The following program demonstrates the vfprintf() function.


Output
Hello Geeks for Geeks .
Successfully wrote 24 characters to the screen.

Reference:https://www.php.net/manual/en/function.vfprintf.php

Comment
Article Tags:
Article Tags: