note 107442 added to function.printf
| From: | rahulmaurya85 at gmail dot com | Date: | Thu, 09 Feb 2012 13:05:35 +0000 |
| Subject: | note 107442 added to function.printf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185938@lists.php.net to get a copy of this message | ||
Printf
Parameters
format
String that contains the text to be written to stdout.
It can optionally contain embedded format tags that are substituted by the values specified in
subsequent argument(s) and formatted as requested.
The number of arguments following the format parameters should at least be as much as the number of
format tags.
The format tags follow this prototype:
%[flags][width][.precision][length]specifier
Where specifier is the most significant one and defines the type and the interpretation of the value
of the coresponding argument:
c = Character a
d or i = Signed decimal integer =392
e =Scientific notation (mantissa/exponent) using e character =3.9265e+2
E =Scientific notation (mantissa/exponent) using E character =3.9265E+2
f=Decimal floating point 392.65
g=Use the shorter of %e or %f 392.65
G=Use the shorter of %E or %f 392.65
o=Unsigned octal 610
s=String of characters sample
u=Unsigned decimal integer 7235
x=Unsigned hexadecimal integer 7fa
X=Unsigned hexadecimal integer (capital letters) 7FA
p=Pointer address B800:0000
n=Nothing printed. The argument must be a pointer to a signed int, where the number of characters
written so far is stored.
% A % followed by another % character will write % to stdout. %
Emp.
<?php
$num = 1;
printf ("Characters: %c %c \n", 'a', 65);
printf ("Decimals: %d %ld\n", 1977, 650000);
printf ("Preceding with blanks: %10d \n", 1977);
printf ("Preceding with zeros: %010d \n", 1977);
printf ("Some different radixes: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
printf ("floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
printf ("Width trick: %*d \n", 5, 10);
printf ("%s \n", "A string");
?>
----
Server IP: 69.147.83.197
Probable Submitter: 117.201.55.184
----
Manual Page -- http://www.php.net/manual/en/function.printf.php
Edit -- https://master.php.net/note/edit/107442
Del: integrated -- https://master.php.net/note/delete/107442/integrated
Del: useless -- https://master.php.net/note/delete/107442/useless
Del: bad code -- https://master.php.net/note/delete/107442/bad+code
Del: spam -- https://master.php.net/note/delete/107442/spam
Del: non-english -- https://master.php.net/note/delete/107442/non-english
Del: in docs -- https://master.php.net/note/delete/107442/in+docs
Del: other reasons-- https://master.php.net/note/delete/107442
Reject -- https://master.php.net/note/reject/107442
Search -- https://master.php.net/manage/user-notes.php