本文章中我们介绍了php中四个常用的取整和四舍五入函数ceil,floor,round,intval ,下面我们来详细介绍.
ceil — 进一法取整
说明
float ceil ( float value )
返回不小于 value 的下一个整数,value 如果有小数部分则进一位.ceil() 返回的类型仍然是 float,因为 float 值的范围通常比 integer 要大.
例子 1. ceil() 例子
实例代码如下:
- <?php
- echo ceil(4.3); // 5
- echo ceil(9.999); // 10
- ?>
在分页时我们会常用到的
//页码计算:
实例代码如下:
- $lastpg=ceil($totle/$displaypg); //最后页,也是总页数
- $lastpg=$lastpg ? $lastpg : 1; //没有显示条目,置最后页为1
- $page=min($lastpg,$page);
- $prepg=$page-1; //上一页
- $nextpg=($page==$lastpg ? 0 : $page+1); //下一页
- $firstcount=($page-1)*$displaypg;
floor — 舍去法取整
说明
float floor ( float value )
返回不大于 value 的下一个整数,将 value 的小数部分舍去取整.floor() 返回的类型仍然是 float,因为 float 值的范围通常比 integer 要大.
例子 1. floor() 例子
例子
在本例中,我们将对不同的数应用 floor() 函数:
实例代码如下:
- <?php
- echo(floor(0.60));
- echo(floor(0.40));
- echo(floor(5));
- echo(floor(5.1));
- echo(floor(-5.1));
- echo(floor(-5.9))
- ?>
输出:
0
0
5
5
-6
-6
round — 对浮点数进行四舍五入
说明
float round ( float val [, int precision] )
返回将 val 根据指定精度 precision(十进制小数点后数字的数目)进行四舍五入的结果.precision 也可以是负数或零(默认值).
注释:PHP 默认不能正确处理类似 "12,300.2" 的字符串.
注释:prec 参数是在 PHP 4 中被引入的..
实例代码如下:
- <?php
- echo(round(0.60));
- echo(round(0.50));
- echo(round(0.49));
- echo(round(-4.40));
- echo(round(-4.60));
- ?>
输出:
1
1
0
-4
-5
intval—对变数转成整数型态
变量转成整数类型.
语法: int intval(mixed var, int [base]);
返回值: 整数
函数种类: PHP 系统功能
内容说明
本函数可将变量转成整数类型.可省略的参数 base 是转换的基底,默认值为 10.转换的变量 var 可以为数组或类之外的任何类型变量.
例子intval()
实例代码如下:
- <?php
- echo intval(4.3); //4
- echo intval(4.6); // 4
- ?>
注:intval如果是字符型的会自动转换为0 如
intval('abc');
输出结果 0
如果是
intval('5fd');
输出结果是
5
波比源码 » php中四舍五入取整函数详细介绍
levofloxacin medication levofloxacin 500mg cost
cialis 20mg ohne rezept sildenafil 100mg ohne rezept sildenafil kaufen für männer
cost accutane 10mg order stromectol 12mg generic ivermectin tablets for sale walmart
buy buspar 5mg for sale cost dilantin order ditropan generic
zoloft cost Free viagra sample sildenafil drug
avlosulfon uk dapsone 100mg cost aceon without prescription
order generic provigil 100mg online canadian pharmacy legit ivermectin tablets order
order chloroquine 250mg sale order generic baricitinib cheap baricitinib 4mg
order itraconazole 100 mg online cheap buy tindamax tindamax order online
linezolid 600mg usa slot games online free poker online free
purchase metoprolol generic cheap metoprolol vardenafil cheap
vardenafil 10mg over the counter pregabalin for sale online buy medrol 4mg
priligy buy online cheap synthroid tablets cheap synthroid generic
order cozaar 50mg for sale order topiramate for sale buy topamax
baclofen 25mg sale buy ketorolac pill toradol 10mg pill
order imitrex 50mg online avodart cost cheap avodart 0.5mg
buy zantac generic buy mobic 15mg generic order celecoxib 100mg pill
real money casino free welcome spins no deposit real online casino
buy diflucan 100mg generic viagra 50mg usa viagra cost
cephalexin 500mg oral order cleocin pills erythromycin 250mg usa
purchase sildalis pills lamotrigine for sale lamotrigine 200mg uk
purchase prednisone generic order deltasone 10mg pills buy generic amoxicillin 250mg
world tavern poker online online card games buy modafinil generic
fildena 50mg generic order budesonide online cheap rhinocort buy online
tadalafil 20mg tablet order tadacip 10mg order indocin 50mg
lamisil 250mg oral cefixime ca order generic trimox 250mg
purchase biaxin pills catapres 0.1mg sale purchase meclizine online
naprosyn 500mg pills omnicef 300 mg pill order prevacid 15mg
buy generic spiriva spiriva us buy terazosin 5mg sale
buy pioglitazone 30mg pill buy pioglitazone 30mg sale viagra 100mg england
cialis 5mg cheap buy tadalafil purchase tadalafil pill
best casino casino slots online casino no deposit bonus
blackjack online for real money online casino bonus slot games free
order adalat 10mg online order adalat 30mg pills brand fexofenadine 120mg
online casino gambling online pharmacy non prescription drugs help with essays
oral altace 10mg altace cost arcoxia 120mg pill
essays help sulfasalazine 500 mg for sale order azulfidine without prescription
cost doxycycline clindamycin without prescription order cleocin 150mg for sale
clobetasol buy online order cordarone order amiodarone 100mg sale
order tadalafil online cheap viagra women best natural ed pills
accutane 40mg cheap buy azithromycin for sale order zithromax 500mg pill
purchase prednisolone furosemide pills order furosemide 40mg for sale
order zyrtec sale how to buy atomoxetine sertraline canada
cenforce 50mg without prescription purchase cenforce order metformin 1000mg for sale
lexapro 20mg over the counter revia 50 mg generic order naltrexone pills
letrozole tablet femara ca viagra 50mg generic
cialis 10mg price buy real cialis fda approved over the counter ed pills
buy generic tadalafil buy ed medications online buy ed pills online
stromectol nz generic stromectol 6mg isotretinoin 10mg pill
buy isotretinoin 20mg pills buy zithromax 250mg generic how to buy zithromax
buy prednisolone 10mg online cheap furosemide price buy furosemide tablets
generic clomiphene 50mg buy clomid 100mg online cheap buy hydroxychloroquine without a prescription
buy atenolol pills for sale buy medrol cheap buy femara 2.5 mg pill
oral synthroid 100mcg order clomid buy vardenafil 10mg sale
albendazole price aripiprazole 20mg ca purchase medroxyprogesterone sale
buy glucophage 500mg generic atorvastatin 40mg generic order amlodipine 10mg online cheap
buy zestril 10mg for sale purchase lopressor pill order lopressor generic
cost pregabalin purchase dapoxetine pill purchase dapoxetine pill
buy generic methotrexate for sale buy methotrexate paypal metoclopramide 10mg pills
order cozaar for sale topamax order online order topiramate 100mg pill
buy rosuvastatin 10mg generic how to buy rosuvastatin cheap domperidone 10mg
buy imitrex 25mg pill sumatriptan usa buy avodart generic
cheap tetracycline 500mg buy baclofen generic order baclofen without prescription
cost ketorolac inderal 10mg cost inderal drug
buy ranitidine 150mg for sale ranitidine 150mg pill order celecoxib 200mg without prescription
order flomax without prescription order flomax purchase aldactone
betnovate 20 gm usa betnovate 20gm usa itraconazole oral
where can i buy combivent buy ipratropium 100mcg online buy cheap zyvox
nateglinide 120 mg without prescription buy captopril 25mg pills atacand 8mg over the counter
order bystolic 5mg pill buy diovan paypal clozapine 100mg sale
buy cheap generic zocor cheap viagra for sale order sildenafil 50mg
order cialis 20mg pill cialis 10mg usa purchase viagra pills
avanafil 200mg for sale order tadalafil 20mg generic voltaren without prescription
nolvadex 10mg uk ceftin 500mg ca ceftin 500mg drug
careprost buy online trazodone buy online trazodone 100mg for sale
azithromycin 250mg without prescription buy neurontin 600mg sale order gabapentin 100mg for sale
lasix canada albuterol for sale buy albuterol 4mg pill
brand levitra tizanidine over the counter buy hydroxychloroquine cheap
buy cheap mesalamine order irbesartan online cheap buy irbesartan 150mg sale
buy temovate tablets amiodarone 100mg tablet amiodarone 100mg pills
buy lanoxin 250mg generic order molnunat 200mg pill buy molnunat 200 mg online
proventil over the counter buy proventil 100mcg pills phenazopyridine price
buy olumiant pills for sale purchase atorvastatin online cheap buy atorvastatin 80mg for sale
order singulair 10mg online montelukast 10mg price buy avlosulfon cheap
buy norvasc tablets order omeprazole omeprazole canada
metoprolol cost medrol 4 mg for sale buy medrol 16 mg online
diltiazem us order zovirax online how to get zyloprim without a prescription
buy aristocort 4mg pill order claritin online claritin cheap
cheap sulfamethoxazole cephalexin generic cleocin 300mg without prescription
where to buy toradol without a prescription ketorolac generic buy generic inderal 20mg
purchase rhinocort for sale bimatoprost cost careprost brand
topiramate brand levofloxacin 500mg canada levofloxacin ca
methocarbamol for sale online purchase desyrel pill suhagra price
cost sildenafil 50mg buy sildalis generic estrace 1mg cheap
buy lamictal 200mg without prescription order minipress for sale minipress usa
brand spironolactone 25mg order valacyclovir 500mg generic order valacyclovir 500mg online cheap
buy tretinoin medication tadalafil 10mg canada buy avana cheap
proscar generic viagra 25mg price viagra 50mg canada
tadalafil us tadalafil tablets sildenafil without prescription
buy tadalafil 10mg without prescription order indocin 75mg capsule buy indomethacin 75mg generic
cialis 10mg drug tadalafil price best ed pills at gnc
lamisil 250mg sale order amoxicillin generic generic trimox 500mg
buy sulfasalazine 500 mg pill purchase calan sale order verapamil generic
arimidex tablet buy arimidex generic clonidine brand
buy meclizine 25mg online buy antivert 25 mg for sale order minocin sale
buy molnupiravir sale buy generic naprosyn online order omnicef 300mg
best ed medication sildenafil 50mg tablets viagra 50mg without prescription
erection problems order tadalafil 10mg online cheap tadalafil 40 mg
order terazosin for sale pioglitazone us buy tadalafil 20mg without prescription
avapro 300mg brand order clobetasol sale buspar 10mg canada
purchase albenza generic buy generic medroxyprogesterone medroxyprogesterone price
oxybutynin where to buy elavil 10mg generic buy alendronate paypal
biltricide 600 mg canada praziquantel pills order periactin 4 mg sale
macrodantin 100 mg generic generic nitrofurantoin 100mg cheap nortriptyline
brand fluvoxamine purchase nizoral generic duloxetine 20mg brand
how to get panadol without a prescription buy paracetamol medication generic pepcid 20mg
clomipramine 25mg without prescription anafranil pills progesterone brand
order prograf generic order requip 2mg sale buy generic ropinirole 2mg
valsartan where to buy order clozapine 50mg without prescription ipratropium 100mcg ca
oral oxcarbazepine 600mg buy oxcarbazepine 600mg online cheap actigall order online
nateglinide where to buy order atacand 8mg tegretol 200mg brand
seroquel 100mg price how to get escitalopram without a prescription purchase escitalopram
where to buy epivir without a prescription buy zidovudine 300mg without prescription buy quinapril tablets
frumil cheap buy adapalene gel for sale buy acivir no prescription
zebeta 5mg canada cost bisoprolol 10mg cheap terramycin 250mg