PHP 之 打印函数
1 <?php 2 header("Content-type:text/html; charset=utf-8"); 3 4 $season = "summertime"; 5 6 #print() 输出到浏览器 7 print("hello world"); 8 echo "<br>"; 9 10 #echo 11 echo "i love $season"; 12 echo "<br>"; 13 14 #printf 如果输出由静态文本和一个或者多个变量中存储的动态信息组成的混合产物使用printf 15 #原型: interger printf(string format [, mixed args]) 16 $count = 100; 17 printf("i have %d apple",$count); 18 echo "<br>"; 19 20 #sprintf 输出直接赋值给一个字符串,而不是直接输出到字符串中 21 $cost = sprintf("$%.2f",43.2); 22 echo $cost; //43.20