显示下拉菜单

printf()

« print_r | quotemeta »
<?php
ob_start
();

$string printf (
    
// string $format
    
// mixed $arg0
    
// mixed $arg1
    
  // mixed $arg2
);

$contents ob_get_contents();
ob_end_clean();
?>
结果
$string = 7
$contents = '29EA6AD'
示例
#1 printf  ("There are %d monkeys in the %s",
 
5,
 
"tree")
#2 printf  ("The %s contains %d monkeys",
 
5,
 
"tree")
#3 printf  ('The %2$s contains %1$d monkeys',
 
5,
 
"tree")
#4 printf  ('The %2$s contains %1$d monkeys. That\'s a nice %2$s full of %1$d monkeys.',
 
5,
 
"tree")
#5 printf  ('The %2$s contains %1$04d monkeys',
 
5,
 
"tree")
#6 printf  ("%b",
 
43951789)
#7 printf  ("%c",
 
65)
#8 printf  ("%d",
 
43951789)
#9 printf  ("%e",
 
43951789)
#10 printf  ("%u",
 
43951789)
#11 printf  ("%u",
 -
43951789)
#12 printf  ("%f",
 
43951789)
#13 printf  ("%o",
 
43951789)
#14 printf  ("%s",
 
43951789)
#15 printf  ("%x",
 
43951789)
#16 printf  ("%X",
 
43951789)
#17 printf  ("%+d",
 
43951789)
#18 printf  ("%+d",
 -
43951789)
#19 printf  ("[%s]",
 
"monkey")
#20 printf  ("[%10s]",
 
"monkey")
#21 printf  ("[%-10s]",
 
"monkey")
#22 printf  ("[%010s]",
 
"monkey")
#23 printf  ("[%'#10s]",
 
"monkey")
#24 printf  ("[%10.10s]",
 
"many monkeys")
#25 printf  ("%04d-%02d-%02d",
 
"2014",
 
"2",
 
"15")
#26 printf  ("%01.2f",
 
123.1)
#27 printf  ("%.3e",
 
362525200)
另请参阅
sprintf, sscanf, vprintf, vsprintf