The PHP Function Fprintf
The php function fprintf writes a formatted string to a stream, like a file or database. It takes a format string and then any number of arguments, which are spliced into the appropriate places in the format string to generate the output. The function also returns the length of the string written.
The list of possible format strings is long and varied. You can use them to print binary numbers, easily output scientific notations (for example, '%E+') and more. You can find the full list in the PHP Manual sprintf page.
In addition to the standard formats, there are some special formats that are used to do other things, such as padding the value with a specific character or pad it with zeros. You can also add a
Other functions in the fprintf family are used to do other kinds of textual manipulations, such as escaping special characters or adding a trailing comma at the end of the list of parameters to a function. Other examples are rtrim(), which removes white space from the right side of a string, and quotemeta(), which puts backslashes before any non-alphanumeric characters in a string to prevent them from being considered as literals.