测试php代码,学习springf()函数

上一篇 / 下一篇  2007-08-05 15:51:37 / 个人分类:学习日志

<?php
$s = 'monkey';
$t = 'many monkeys';

printf("[%s]\n", $s); // standard string output
printf("[%10s]\n", $s); // right-justification with spaces
printf("[%-10s]\n", $s); // left-justification with spaces
printf("[%010s]\n", $s); // zero-padding works on strings too
printf("[%'#10s]\n", $s); // use the custom padding character '#'
printf("[%10.10s]\n", $t); // left-justification but with a cutoff of 10 characters

$money = 1.4;
$formatted = sprintf ("%-02.2f", $money);
echo $formatted;

$number = 123;
$txt = sprintf("%f",$number);
echo $txt;
?>


TAG: 学习日志

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

数据统计

  • 访问量: 576
  • 日志数: 8
  • 建立时间: 2006-12-14
  • 更新时间: 2007-08-05

RSS订阅

Open Toolbar