PHP fprintf() Function
You are Here:
PHP fprintf()
The fprintf()
function writes a formatted string to a specified output stream.
Warning: The c type specifier ignores padding and width.
Example
PHP Compiler
<?php
$count = 9;
$file = fopen("fruits.txt", "w");
echo fprintf($file, "I have %f apples.", $count);
?>
Output
23
The following text is written to the file 'fruit.txt'
I have 9.000000 apples.
Syntax
fprintf(handle, format, arg1, arg2, ...)
Parameter Values
Value | Type | Explanation |
---|---|---|
handle | Required | Specifies a file system pointer resource that is typically created using fopen(). |
format | Required | Specifies the string and how to format the variables in it. Possible format values:
|
arg1 | Required | The argument to be added as the first %-sign in the formatted string. |
arg2, .. | Optional | The argument to be added as the second %-sign in the formatted string and so on. |
Return Value
Value | Explanation |
---|---|
Number | Returns the length of the string written. |
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on PHP with examples for quick and easy learning.
We are working to cover every Single Concept in PHP.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.