diff --git a/reference/strings/functions/fprintf.xml b/reference/strings/functions/fprintf.xml index 4e5cd6e575..f339e04de9 100644 --- a/reference/strings/functions/fprintf.xml +++ b/reference/strings/functions/fprintf.xml @@ -1,5 +1,5 @@ - + fprintf @@ -14,111 +14,11 @@ mixedargs - Write a string produced according to the formatting string - format to the stream resource specified - by handle.. + Write a string produced according to format + to the stream resource specified by handle. + format is described in the documentation for + sprintf. - - The format string is composed of zero or more directives: - ordinary characters (excluding %) that are - copied directly to the result, and conversion - specifications, each of which results in fetching its - own parameter. This applies to fprintf, - sprintf, and printf. - - - Each conversion specification consists of a percent sign - (%), followed by one or more of these - elements, in order: - - - - An optional padding specifier that says - what character will be used for padding the results to the - right string size. This may be a space character or a - 0 (zero character). The default is to pad - with spaces. An alternate padding character can be specified - by prefixing it with a single quote ('). - See the examples below. - - - - - An optional alignment specifier that says - if the result should be left-justified or right-justified. - The default is right-justified; a - - character here will make it left-justified. - - - - - An optional number, a width specifier - that says how many characters (minimum) this conversion should - result in. - - - - - An optional precision specifier that says - how many decimal digits should be displayed for floating-point - numbers. This option has no effect for other types than - float. (Another function useful for formatting numbers is - number_format.) - - - - - A type specifier that says what type the - argument data should be treated as. Possible types: - - - % - a literal percent character. No - argument is required. - - - b - the argument is treated as an - integer, and presented as a binary number. - - - c - the argument is treated as an - integer, and presented as the character with that ASCII - value. - - - d - the argument is treated as an - integer, and presented as a (signed) decimal number. - - - u - the argument is treated as an - integer, and presented as an unsigned decimal number. - - - f - the argument is treated as a - float, and presented as a floating-point number. - - - o - the argument is treated as an - integer, and presented as an octal number. - - - s - the argument is treated as and - presented as a string. - - - x - the argument is treated as an integer - and presented as a hexadecimal number (with lowercase - letters). - - - X - the argument is treated as an integer - and presented as a hexadecimal number (with uppercase - letters). - - - - - - Returns the length of the outputted string. @@ -134,26 +34,36 @@ Examples - <function>sprintf</function>: zero-padded integers + <function>fprintf</function>: zero-padded integers ]]> - <function>sprintf</function>: formatting currency + <function>fprintf</function>: formatting currency ]]> diff --git a/reference/strings/functions/sprintf.xml b/reference/strings/functions/sprintf.xml index 1845a50e55..395c063a19 100644 --- a/reference/strings/functions/sprintf.xml +++ b/reference/strings/functions/sprintf.xml @@ -1,5 +1,5 @@ - + @@ -60,9 +60,8 @@ An optional precision specifier that says how many decimal digits should be displayed for floating-point - numbers. This option has no effect for other types than - float. (Another function useful for formatting numbers is - number_format.) + numbers. When using this specifier on a string, it acts as a + cutoff point, setting a maximum character limit to the string. @@ -191,20 +190,91 @@ printf($format, $num, $location); Examples - - - <function>sprintf</function>: zero-padded integers - + + <function>printf</function>: various examples + + +]]> + + + The printout of this program would be: + + + + + + + <function>printf</function>: string specifiers + + +]]> + + + The printout of this program would be: + + + + + + + <function>sprintf</function>: zero-padded integers + ]]> - - - - <function>sprintf</function>: formatting currency - + + + + <function>sprintf</function>: formatting currency + ]]> - - - - <function>sprintf</function>: scientific notation - + + + + <function>sprintf</function>: scientific notation + ]]> - - - + +