Type Specifiers for printf() and sprintf() : sprintf « Development « PHP






Type Specifiers for printf() and sprintf()

Specifier           Input type                   Output Format

b                   Integer                      Binary number

C                   Integer                      Single character

D                   Integer                      Signed decimal number

U                   Integer                      Unsigned decimal number

F                   Floating-point number        Floating-point number

O                   Integer                      Octal number

S                   String                       String

X                   Integer                      Hexadecimal number with lowercase letters

X                   Integer                      Hexadecimal number with uppercase letters
           
       








Related examples in the same category

1.sprintf %0.2f
2.sprintf: Regards the string an integer and formats it as a binary number
3.sprintf: Considers the string an integer and formats it with that ASCII value
4.sprintf: Considers the string an integer and formats it as a decimal number