ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

5-3-3 printf()¨ç¼Æ

5-3-3 printf()¨ç¼Æ

5-3-3   printf()¨ç¼Æ
printf()¨ç¼Æ¥i®Ú¾Ú§Ú­Ìªº®æ¦¡³]©w¨Ó¿é¥X®æ¦¡¤Æªº¦r¦ê¡Aprintf()¨ç¼Æ¸òprint()¨ç¼Æ¤£¦P¡A¸ê®Æ¿é¥X«á¤£·|¦³¦^¶Ç­È¡G
printf()¨ç¼Æ®æ¦¡
  1. void printf ( string format [, mixed args])
½Æ»s¥N½X
¤W¦¡¤¤¡G¡uformat¡v¬°®æ¦¡³]©w¡A¨Ò¦p¡G
  1. <?
  2. $age="20 ·³";
  3. printf("%d" ,"$age"); //¿é¥X20
  4. ?>
½Æ»s¥N½X
¤W¨Ò¤¤¡A§Ú­Ìªº®æ¦¡³]©w¬°¡u%d¡v¤D¬O±N¦r¦ê¡u"20 ·³"¡v®æ¦¡¤Æ¬°¤Q¶i¨î¸ê®Æ¦Ó¿é¥X¡u20¡v¡C
¨Ò¦p¡G¿é¥X¤p¼ÆÂI«á3¦ì¤p¼Æªº¯BÂI«ü¼Æ
  1. <?
  2. $age="20 ·³";
  3. printf("%.3e" ,"$age"); //¿é¥X2.00e+1
  4. ?>
½Æ»s¥N½X
®æ¦¡¤Æªº¦r¦ê¤¤¤]¥i¥H¥]§t§Ú­Ì­nÅã¥Üªº¤å¦r¡A¨Ò¦p¡G
  1. <?
  2. $age="20 ·³";
  3. printf("§Ú%.3e·³" ,"$age"); //§Ú2.00e+1·³  
  4. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

¤Uªí¬°®æ¦¡¤Æªº¥i¥Î¸ê®ÆÃþ«¬¡G
Ãþ«¬»¡©ú
%®æ¦¡¤Æªº«e¸m²Å¸¹
c¦r¤¸
s¦r¦ê
d¤Q¶i¨î¾ã¼Æ
b¤G¶i¨î¾ã¼Æ
o¤K¤G¶i¨î¾ã¼Æ
x¤p¼gªº¤Q¤»¶i¨î¾ã¼Æ
X¤j¼gªº¤Q¤»¶i¨î¾ã¼Æ
f¯BÂI¼Æ
e«ü¼Æ



printf()¨ç¼Æ¥ç¥i¥Î©ó¸m´«¦P®É®æ¦¡¤Æ¡A¨Ò¦p¡G
  1. <?
  2. $name="©~©ö";
  3. $tall="170";
  4. $me="§Úªº¦W¦r¬O %s ,¨­°ª %X ¤½¤À";
  5. printf($me , $name , $tall);
  6. //¿é¥X:§Úªº¦W¦r¬O ©~©ö,¨­°ª AA ¤½¤À  
  7. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¯¸¦b¥b¸ô¡A¤ñ¨«¨ì¥Ø¼Ð§ó¨¯­W¡C
ªð¦^¦Cªí ¤W¤@¥DÃD