diff --git a/reference/strings/functions/sprintf.xml b/reference/strings/functions/sprintf.xml index dec96308de..3a29d12389 100644 --- a/reference/strings/functions/sprintf.xml +++ b/reference/strings/functions/sprintf.xml @@ -1,5 +1,5 @@ - + @@ -31,6 +31,15 @@ (%), followed by one or more of these elements, in order: + + + An optional sign specifier that forces a sign + (- or +) to be used on a number. By default, only the - sign is used + on a number if it's negative. This modifier forces positive numbers + to have the + sign attached as well. This specifier was added in + PHP 4.3.0. + + An optional padding specifier that says @@ -97,7 +106,7 @@ f - the argument is treated as a - float, and presented as a floating-point number. + float, and presented as a floating-point number. o - the argument is treated as an @@ -212,6 +221,9 @@ printf("%%o = '%o'\n", $n); // octal representation printf("%%s = '%s'\n", $n); // string representation printf("%%x = '%x'\n", $n); // hexadecimal representation (lower-case) printf("%%X = '%X'\n", $n); // hexadecimal representation (upper-case) + +printf("%%+d = '%+d'\n", $n); // sign specifier on a positive integer +printf("%%+d = '%+d'\n", $u); // sign specifier on a negative integer ?> ]]> @@ -231,6 +243,8 @@ printf("%%X = '%X'\n", $n); // hexadecimal representation (upper-case) %s = '43951789' %x = '29ea6ad' %X = '29EA6AD' +%+d = '+43951789' +%+d = '-43951789' ]]>