printf()函数优点在于可以格式化输出!
格式如下:%[‘padding_character][-][width][.precision]type
所有的转换说明都是以%开始,如果想打印一个%符号,必须用%%.
参数’padding_character是可选.它将被用来填充变量直至所指定的宽度.该参数的作用就在变量前面填充.默认的填充字符是一个空格,如果指定0或者空格,就不需要 ‘ 单引号作为前缀,其他字符就必须指定 ‘ 作为前缀.
参数 – 是可选.它指左对齐,默认是右对齐.
参数width是指被替换的变量的长度.
参数precision表示以小数点开始.它指明小数点后要显示的位数.
参数type 是类型码,请看下表:
类型 | 含义
b | 解释为整数并作为二进制输出.
c | 解释为整数并作为字符表示输出(ASCII码).
d | 解释为整数并作为整数输出.
f | 解释为双精度并作为浮点数输出.
o | 解释为整数并作为八进制数输出.
s | 解释为字符串并为字符串输出.
u | 解释为整数并作为非指定小数输出.
x | 解释为整数并作为带有小写字母a-f的十六进制数输出
X | 解释为整数并作为带有大写字母A-F的十六进制数输出
演示:
———————————————————————————————
<?php
$str = "0758 jian";
$strA = "A";
$strB = "B";
$num1 = 5;
$num2 = 5;
$num3 = 0.25;
$num4 = 3.2567;
$num5 = 8;
$num6 = 1.735;
$num7 = 16777215;
$num8 = 16777215;
printf("%2$s %1$s", $strA, $strB); // 2$是指定参数位置
echo ‘<br />’;
printf("填充: %’%10s", $str); //指定填充符为%字符串宽度为10
echo ‘<br />’;
printf("二制制: %b", $num1);
echo ‘<br />’;
printf("ASCII码: %c", $num2);
echo ‘<br />’;
printf("整数: %d", $num3);
echo ‘<br />’;
printf("浮点数: %.2f", $num4);
echo ‘<br />’;
printf("八进制: %o", $num5);
echo ‘<br />’;
printf("字符串: %s", $str);
echo ‘<br />’;
printf("非小数: %u", $num6);
echo ‘<br />’;
printf("十六进制: %x", $num7);
echo ‘<br />’;
printf("十六进制: %X", $num8);
?>
———————————————————————————————
输出结果:
———————————————————————————————
B A
填充: %0758 jian
二制制: 101
ASCII码:
整数: 0
浮点数: 3.26
八进制: 10
字符串: 0758 jian
非小数: 1
十六进制: ffffff
十六进制: FFFFFF
波比源码 » PHP语言中 printf()函数格式化使用详解
order levaquin 500mg pills order levaquin 500mg sale
order cialis 20mg sale cialis coupon walmart sildenafil 200mg
aralen cost brand cenforce buy baricitinib online cheap
order cozaar without prescription buy nexium 20mg sale topamax 100mg ca
online roulette free casino online blackjack poker online free
order tadalafil 5mg generic cialis savings card sildenafil 50mg for sale
casino free spin rx pharmacy online cialis cheap tadalafil online
order trazodone 100mg generic suhagra 100mg brand sildenafil 100mg uk
tretinoin gel sale generic avana cheap avanafil
naprosyn 500mg pills lansoprazole 15mg brand lansoprazole 15mg for sale
order clarithromycin 500mg pills clonidine sale cost meclizine 25 mg
oral singulair 10mg viagra 100mg over the counter cheap sildenafil pills
tadalafil ca Buy cialis on line cialis pills
oral ivermectin cost oral dapsone 100 mg order avlosulfon 100 mg pill
nifedipine online order aceon 8mg online buy fexofenadine 120mg sale
buy altace for sale order amaryl for sale buy etoricoxib pills
doxycycline buy online order doxycycline generic cleocin 150mg drug
brand lanoxin 250 mg buy molnupiravir for sale order molnunat generic
order carvedilol 25mg generic buy coreg online cheap order elavil 50mg online cheap
buy amoxicillin 250mg without prescription order stromectol sale stromectol 0.1
fosamax 35mg usa order alendronate 70mg order motrin generic
Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
buy doxycycline 200mg pills doxycycline online methylprednisolone buy
generic ropinirole 1mg trandate 100mg for sale order labetalol 100mg generic
glycomet 1000mg canada order verapamil 120mg pills buy nolvadex pill
buy generic modafinil 200mg generic phenergan order phenergan without prescription
buy isotretinoin 20mg online cheap isotretinoin 20mg price ampicillin 500mg pills
fildena us propecia 5mg sale cost finasteride
ivermectin 12 mg tablets causes of ed purchase prednisone online cheap
ondansetron 8mg sale generic sulfamethoxazole bactrim for sale online
accutane price zithromax 250mg cost order azithromycin 250mg
cost prednisolone 40mg prednisolone 5mg without prescription buy furosemide 100mg pills
cefdinir 300mg brand cefdinir 300mg for sale order pantoprazole 40mg generic
order ezetimibe 10mg online ezetimibe for sale online methotrexate where to buy
coumadin 5mg uk allopurinol drug allopurinol pills
I really love to read such an excellent article. Helpful article. Hello Administ .Click on the Keyword to Enter the Website. deneme bonusu
amoxicillin tablets amoxil 250mg ca order prednisolone 20mg online
accutane us buy isotretinoin tablets zithromax 250mg cheap
buy generic gabapentin for sale buy doxycycline pills doxycycline 100mg ca
prednisolone 10mg canada neurontin price order furosemide 100mg online cheap
vibra-tabs generic buy generic albuterol 4mg order amoxiclav online cheap
buy rosuvastatin 20mg online buy ezetimibe sale brand domperidone
purchase toradol online cheap buy cheap generic colcrys inderal 10mg for sale
ranitidine 300mg drug celecoxib oral celecoxib 100mg cost
duloxetine medication order duloxetine 40mg for sale order nootropil 800mg pill
progesterone 200mg ca tindamax online order order zyprexa 10mg generic
nebivolol 20mg brand cost clozaril 50mg purchase clozapine pills
cheap carbamazepine order tegretol for sale order lincomycin 500 mg generic
cialis from canada Fda approved viagra cheap viagra without prescription
buy generic estradiol estrace 1mg pill purchase prazosin without prescription
buy vermox 100mg online cheap buy mebendazole no prescription tadalis 10mg price
avanafil 200mg for sale avana buy online brand cambia
nolvadex 10mg canada tamoxifen 10mg pill order cefuroxime online
order amoxicillin 500mg pill oral trimox clarithromycin order
buy azithromycin 250mg generic omnacortil order online gabapentin cost
buy generic vardenafil over the counter plaquenil order plaquenil 200mg us
order ramipril 5mg online buy glimepiride without prescription purchase etoricoxib without prescription
order vardenafil 10mg generic buy hydroxychloroquine 200mg pills buy plaquenil 400mg pill
buy generic asacol 400mg asacol where to buy buy generic avapro over the counter
buy benicar 10mg pill buy depakote without prescription buy divalproex no prescription
acetazolamide 250mg cheap order azathioprine generic order generic imuran 25mg
naprosyn 250mg uk order naprosyn 500mg without prescription order lansoprazole pill
albuterol 100 mcg pill proventil 100mcg cheap buy phenazopyridine online cheap
purchase baricitinib pill buy lipitor 80mg for sale order generic atorvastatin 10mg
buy singulair 10mg without prescription order generic montelukast 10mg order generic avlosulfon
order norvasc 10mg pill omeprazole 10mg brand prilosec 20mg pill
nifedipine 30mg pills buy nifedipine 10mg generic order fexofenadine 180mg for sale
dapoxetine pills order dapoxetine generic xenical 60mg ca
purchase lopressor sale medrol 8 mg online medrol tablet
buy rosuvastatin 20mg online order rosuvastatin 10mg without prescription order motilium pill
ampicillin pill ampicillin pill order flagyl without prescription
sumycin 500mg price buy baclofen 10mg online cheap ozobax online buy
cheap septra order generic cleocin cleocin cheap
order toradol 10mg pill buy generic gloperba online inderal for sale
order reglan 20mg sale order cozaar 50mg order nexium without prescription
buy robaxin 500mg sale buy generic trazodone 100mg purchase suhagra
dutasteride oral mobic where to buy generic meloxicam 7.5mg
order aurogra 100mg without prescription oral estrace 1mg buy estrace pills for sale
order celecoxib 100mg generic purchase celecoxib pill zofran 4mg us
order lamotrigine buy lamictal 50mg generic order prazosin 1mg sale
buy aldactone without prescription buy aldactone without prescription valtrex for sale
purchase tretinoin avana us cheap avanafil 100mg
finasteride over the counter us viagra sales viagra 50mg tablet
order cialis 20mg pill sildenafil citrate 50mg purchase viagra sale
cialis tadalafil 5mg order cialis 10mg generic buy best erectile dysfunction pills
buy terbinafine 250mg pills suprax over the counter trimox 500mg ca
divalproex 250mg uk purchase depakote generic buy cheap generic isosorbide
imuran 25mg usa digoxin 250mg cheap brand micardis 20mg
buy molnunat sale naproxen for sale online purchase cefdinir pills
best otc ed pills cialis over the counter oral cialis
where to buy phenazopyridine without a prescription pyridium where to buy order amantadine pills
buy ed pills sale order tadalafil 20mg sale buy tadalafil 40mg pills
dapsone 100 mg brand oral aceon 8mg generic aceon 4mg
allegra where to buy purchase fexofenadine brand glimepiride
order hytrin 1mg pill order arava 20mg generic brand tadalafil 10mg
buy avapro 300mg online buspar 10mg tablet buy generic buspirone over the counter
cost amiodarone 200mg oral carvedilol oral dilantin 100mg
purchase oxybutynin online order elavil pills purchase alendronate sale
furadantin 100mg drug nortriptyline us nortriptyline 25mg cost
buy luvox without prescription buy nizoral 200mg online cheap duloxetine medication
buy generic panadol online buy famotidine 20mg pill purchase pepcid generic
order diovan 160mg generic combivent online order buy generic ipratropium over the counter
decadron 0,5 mg pill decadron sale starlix generic
order trileptal oral alfuzosin order urso 150mg without prescription
purchase zyban generic cheap bupropion 150 mg buy strattera online
buy capoten sale order atacand carbamazepine over the counter
buy ciplox 500 mg generic ciprofloxacin sale duricef 500mg ca
where to buy seroquel without a prescription order zoloft 50mg for sale purchase lexapro sale
buy fluoxetine 40mg for sale buy generic sarafem 40mg buy femara 2.5 mg for sale
buy zebeta 5mg online cheap bisoprolol 5mg uk oxytetracycline ca
valaciclovir 1000mg pill buy valaciclovir paypal buy floxin 200mg for sale