配色: 字号:
学习 PHP中文函数
2016-08-31 | 阅:  转:  |  分享 
  
学习PHP中文函数

函数Abs()

描述:

mixedabs(mixednumber);

Returnstheabsolutevalueofnumber.Iftheargumentnumberisfloat,returntypeisalsofloat,otherwiseitisint(返回所输的数字的绝对值,浮点型返回浮点型,其他返回整型)

函数Acos()

描述:

floatacos(floatarg);

Returnsthearccosineofarginradians(返回角的余弦值)

AdabasD功能

函数ada_afetch()

描述:

fetcharesultrowintoanarray(返回结果到一个数组里)

函数ada_autocommit()

描述:

toggleautocommitbehaviour

函数ada_close()

描述:

closeaconnectiontoanAdabasDserver(关掉一个数据库的关联)

函数ada_commit()

描述:

commitatransaction(提交一个处理)

函数ada_connect()

描述:

connecttoanAdabasDdatasource(联接一个数据库)

函数ada_exec()

描述:

prepareandexecuteaSQLstatement(执行一个SQL语句)

函数ada_fetchrow()

描述:

fetcharowfromaresult(从数据库中取一条记录)

函数ada_fieldname()

描述:

getthecolumnname(得到字段名)

函数ada_fieldnum()

描述:

getcolumnnumber(得到字段的总数)

函数ada_fieldtype()

描述:

getthedatatypeofafield(取得字段的类型)

函数ada_freeresult()

描述:

freeresourcesassociatedwitharesult

函数ada_numfields()

描述:

getthenumberofcolumnsinaresult(在结果中得到字段数目)

函数ada_numrows()

描述:

numberofrowsinaresult(所取结果的记录数)

函数ada_result()

描述:

getdatafromresults(得到结果的数据)

函数ada_resultall()

描述:

printresultasHTMLtable(以HTML的格式输出结果)

函数ada_rollback()

描述:

rollbackatransaction

函数apache_lookup_uri()

描述:

PerformapartialrequestforthespecifiedURIandreturnallinfoaboutit,ThisperformsapartialrequestforaURI.Itgoesjustfarenoughtoobtainalltheimportantinformationaboutthegivenresourceandreturnsthisinformationinaclass.Thepropertiesofthereturnedclassare:

status:the_request、status_line、method、content_type、handler

uri:filename、path_info、args、boundary、no_cache、no_local_copy、allowed、send_bodyct、bytes_sent、byterange、clength、unparsed_urimtime、request_time

函数apache_note()

描述:

Getandsetapacherequestnotes,apache_note()isanApache-specificfunctionwhichgetsandsetsvaluesinarequest''snotestable.Ifcalledwithoneargument,itreturnsthecurrentvalueofnotenote_name.Ifcalledwithtwoarguments,itsetsthevalueofnotenote_nametonote_valueandreturnsthepreviousvalueofnotenote_name.

函数getallheaders()

描述:

FetchallHTTPrequestheaders(取得所有HTTP头部请求)

例子:

$headers=getallheaders();

while(list($header,$value)=each($headers)){

echo"$header:$value

\n";

}

这个例子将显示返回所有最近的头部请求。

注:此函数只支持APACHE下的PHPisanApache-specificfunctionwhichisequivalenttoinmod_include.ItperformsanApachesub-request.ItisusefulforincludingCGIscriptsor.shtmlfiles,oranythingelsethatyouwouldparsethroughApache.NotethatforaCGIscript,thescriptmustgeneratevalidCGIheaders.AttheminimumthatmeansitmustgenerateaContent-typeheader.

函数virtual()

描述:

virtual()

数组函数example

函数array()

描述:

建立一个数组

arrayarray(...)传回一数组的值,这些值可以用=>来附值。

下面说明了如何构建一个二维数组,及如何指定这个数组的key,以及在正常的数组中以跳序的方式去指定数组的值。

Example1.array()

$fruits=array(

"fruits"=>array("a"=>"orange","b"=>"banana","c"=>"apple"),

"numbers"=>array(1,2,3,4,5,6),

"holes"=>array("first",5=>"second","third")

);

函数array_walk()

描述:

用函数的方式对每个数组的元素做处理

intarray_walk(arrayarr,stringfunc);

使用一个叫FUNC的函数对ARR的每个元素做处理,那些元素将当成是首传给FUNC的参数;如果FUNC需要超过一个参数,则在每次array_walk()呼叫FUNC时都产生一个警告信息,这些警告信息是可以消除的,只要把''@''符号加在array_walk()之前即可。

注意:FUNC会直接对ARR中的元素做处理,所以任何元素的变化将直接改变其在数组中的值。

Example1.array_walk()example

$fruits=array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");

functiontest_alter($item1){$item1=''bogus'';}

functiontest_print($item2){echo"$item2

\n";}

array_walk($fruits,''test_print'');

array_walk($fruits,''test_alter'');

array_walk($fruits,''test_print'');

函数arsort()

描述:

以倒序的方式排列一数组但其序数则不变

voidarsort(arrayarray);

Thisfunctionsortsanarraysuchthatarrayindicesmaintaintheircorrelationwiththearrayelementstheyareassociwww.shanxiwang.netatedwith.Thisisusedmainlywhensortingassociativearrayswheretheactualelementorderissignificant.Example1.arsort()example

$fruits=array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");

arsort($fruits);

for(reset($fruits);$key=key($fruits);next($fruits)){

echo"fruits[$key]=".$fruits[$key]."\n";

}

Thisexamplewoulddisplay:fruits[a]=orangefruits[d]=lemonfruits[b]=bananafruits[c]=appleThefruitshavebeensortedinreversealphabeticalorder,andtheindexassociatedwitheachelementhasbeenmaintained.

函数asort()

描述:

顺序排列一数组且其序数不变

voidasort(arrayarray);

Thisfunctionsortsanarraysuchthatarrayindicesmaintaintheircorrelationwiththearrayelementstheyareassociatedwith.Thisisusedmainlywhensortingassociativearrayswheretheactualelementorderissignificant.Example1.asort()example



$fruits=array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");

asort($fruits);

for(reset($fruits);$key=key($fruits);next($fruits)){

echo"fruits[$key]=".$fruits[$key]."\n";

}



Thisexamplewoulddisplay:fruits[c]=applefruits[b]=bananafruits[d]=lemonfruits[a]=orangeThefruitshavebeensortedinalphabeticalorder,andtheindexassociatedwitheachelementhasbeenmaintained.



函数count()

描述:

计算一变量中元素的个数

intcount(mixedvar);

Returnsthenumberofelementsinvar,whichistypicallyanarray(sinceanythingelsewillhaveoneelement).

Returns0ifthevariableisnotset.

Returns1ifthevariableisnotanarray.

函数current()

描述:

传回数组指针目前所指的元素

mixedcurrent(arrayarray);

Eacharrayvariablehasaninternalpointerthatpointstooneofitselements.Inaddition,alloftheelementsinthearray



arelinkedbyabidirectionallinkedlistfortraversingpurposes.Theinternalpointerpointstothefirstelementthatwas



insertedtothearrayuntilyourunoneofthefunctionsthatmodifythatpointeronthatarray.

Thecurrent()functionsimplyreturnsthearrayelementthat''scurrentlybeingpointedbytheinternalpointer.Itdoesnot



movethepointerinanyway.Iftheinternalpointerpointsbeyondtheendoftheelementslist,current()returnsfalse.

函数each()

描述:

返回数组中下一对key/value的值

arrayeach(arrayarray);

Returnsthecurrentkey/valuepairfromthearrayarrayandadvancesthearraycursor.Thispairisreturnedinafour-



elementarray,withthekeys0,1,key,andvalue.Elements0andkeyeachcontainthekeynameofthearrayelement,and



1andvaluecontainthedata.

Example1.each()examples

$foo=array("bob","fred","jussi","jouni");$bar=each($foo);

$barnowcontainsthefollowingkey/valuepairs:

0=>0

1=>''bob''

key=>0

value=>''bob''

$foo=array("Robert"=>"Bob","Seppo"=>"Sepi");$bar=each($foo);

$barnowcontainsthefollowingkey/valuepairs:

0=>''Robert''

1=>''Bob''

key=>''Robert''

value=>''Bob''

Example2.Traversing$HTTP_POST_VARSwitheach()

echo"ValuessubmittedviaPOSTmethod:
";

while(list($key,$val)=each($HTTP_POST_VARS)){

echo"$key=>$val
";

}

函数end()

描述:

将数组中的指针移到最后一个

end(arrayarray);

end()advancesarray''sinternalpointertothelastelement.

函数key()

描述:

从一数组中取出key

mixedkey(arrayarray);

key()returnstheindexelementofthecurrentarrayposition.

函数ksort()

描述:

以key来排列一数组

Example1.ksort()example

$fruits=array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");

ksort($fruits);

for(reset($fruits);

$key=key($fruits);

next($fruits)){echo"fruits[$key]=".$fruits[$key]."\n";}

Thisexamplewoulddisplay:fruits[a]=orangefruits[b]=bananafruits[c]=applefruits[d]=lemon

函数list()

描述:

用类似数组的方式去指定一整串变量的值

Example1.list()example






while(list($id,$name,$salary)=mysql_fetch_row($result)){

print("\n"."\n"."\n"."\n");

}

?>

EmployeenameSalary
$name$salary


函数next()

描述:

将数组的指向指到下一组数据



函数pos()

描述:

传回数组的当前的数据

函数prev()

描述:

传回数组的前一条的数据

函数reset()

描述:

数组的指针指到第一条

函数rsort()

描述:

以倒序方式排列一个数组

Example1.rsort()example

$fruits=array("lemon","orange","banana","apple");

rsort($fruits);

for(reset($fruits);($key,$value)=each($fruits);){

echo"fruits[$key]=".$value."\n";

}

Thisexamplewoulddisplay:fruits[0]=orangefruits[1]=lemonfruits[2]=bananafruits[3]=appleThefruitshavebeen



sortedinreversealphabeticalorder.

函数sizeof()

描述:

取得一个数组的大小和元素的数目

函数sort()

描述:

排序数组

Example1.sort()example

$fruits=array("lemon","orange","banana","apple");

sort($fruits);

for(reset($fruits);

$key=key($fruits);

next($fruits)){

echo"fruits[$key]=".$fruits[$key]."\n";

}

Thisexamplewoulddisplay:fruits[0]=applefruits[1]=bananafruits[2]=lemonfruits[3]=orangeThefruitshavebeen



sortedi



函数uasort()

描述:

以自定义的方式排列一个数组且序列不变。



函数uksort()

描述:

以自定义的方式以key排列

Thisfunctionwillsortthekeysofanarrayusingauser-suppliedcomparisonfunction.Ifthearrayyouwishtosortneedstobesortedbysomenon-trivialcriteria,youshouldusethisfunction.Example1.uksort()example

functionmycompare($a,$b){

if($a==$b)return0;

return($a>$b)?-1:1;

}

$a=array(4=>"four",3=>"three",20=>"twenty",10=>"ten");

uksort($a,mycompare);

while(list($key,$value)=each($a)){

echo"$key:$value\n";

}



Thisexamplewoulddisplay:20:twenty10:ten4:four3:three

函数usort()

描述:

以自定义的方式以value排列



voidusort(arrayarray,functioncmp_function);



Thisfunctionwillsortanarraybyitsvaluesusingauser-suppliedcomparisonfunction.Ifthearrayyouwishtosortneedstobesortedbysomenon-trivialcriteria,youshouldusethisfunction.Example1.usort()example



functioncmp($a,$b){

if($a==$b)return0;

return($a>$b)?-1:1;

}

$a=array(3,2,5,6,1);

usort($a,cmp);

while(list($key,$value)=each($a)){

echo"$key:$value\n";

}





Thisexamplewoulddisplay:0:61:52:33:24:1Obviouslyinthistrivialcasethersort()functionwouldbemoreappropriate.

BC(ArbitraryPrecision)Functions





函数bcadd()

描述:

Addtwoarbitraryprecisionnumbers

stringbcadd(stringleftoperand,stringrightoperand,int[scale]);左面的字符加右面的字符,返回一个字符。





函数bccomp()

描述:

intbccomp(stringleftoperand,stringrightoperand,int[scale]);

左面的字符和右面的字符进行比较,如果相等的话返回0,如果左面的比右面的长返回+1,右面的比左面的长返回-1





函数bcdiv()

描述:

Dividetwoarbitraryprecisionnumbers

stringbcdiv(stringleftoperand,stringrightoperand,int[scale]);将左面的字符串以右面的字符串为标准分开





函数bcmod()

描述:

Getmodulusofanarbitraryprecisionnumber

stringbcmod(stringleftoperand,stringmodulus);

用右面的modulus操作左面的字符串





函数bcmul()

描述:

Multiplytwoarbitraryprecisionnumber

stringbcmul(stringleftoperand,stringrightoperand,int[scale]);

Multiplytheleftoperandbytherightoperandandreturnstheresult.Theoptionalscalesetsthenumberofdigits

afterthedecimalplaceintheresult.





函数bcpow()

描述:

Raiseanarbitraryprecisionnumbertoanother.

Raisextothepowery.Thescalecanbeusedtosetthenumberofdigitsafterthedecimalplaceintheresult.





函数bcscale()

描述:

Setdefaultscaleparameterforallbcmathfunctions.

stringbcscale(intscale);

Thisfunctionsetsthedefaultscaleparameterforallsubsequentbcmathfunctionsthatdonotexplicitlyspecifyascale

parameter





函数bcsqrt()

描述;

stringbcsqrt(stringoperand,intscale);

返回字符的平方根





函数bcsub()

描述:

stringbcsub(stringleftoperand,stringrightoperand,int[scale]);

将右面的字符减去左面的字符





CalendarFunctions日历功能





函数JDToGregorian()

描述:

stringjdtogregorian(intjulianday);

将Julian日历转换成Gregorian日历





函数GregorianToJD()

描述:

intgregoriantojd(intmonth,intday,intyear);

将Gregorian日历转换成Julian日历





函数JDToJulian()

描述:

stringjdtojulian(intjulianday);

将JulianCalendar转换JulianDay





函数JulianToJD()

描述:

intjuliantojd(intmonth,intday,intyear);





函数JDToJewish()

描述:

ConvertsaJulianDayCounttotheJewishCalendar

stringjdtojewish(intjulianday);





函数JewishToJD()

描述:

ConvertsadateintheJewishCalendartoJulianDayCount

intjewishtojd(intmonth,intday,intyear);





函数JDToFrench()

描述:

ConvertsaJulianDayCounttotheFrenchRepublicanCalendar

stringjdtofrench(intmonth,intday,intyear);





函数FrenchToJD()

描述:

ConvertsadatefromtheFrenchRepublicanCalendartoaJulianDayCountintfrenchtojd(intmonth,intday,intyear);

函数JDMonthName()

描述:

Returnsamonthname

stringjdmonthname(intjulianday,intmode);

ModeMeaning

0Gregorian-apreviated

1Gregorian

2Julian-apreviated

3Julian

4Jewish

5FrenchRepublican

函数JDDayOfWeek()

描述:

Returnsthedayoftheweek

mixedjddayofweek(intjulianday,intmode);

ModeMeaning

0returnsthedaynumberasanint(0=sunday,1=monday,etc)

1returnsstringcontainingthedayofweek(english-gregorian)

2returnsastringcontainingtheabreviateddayofweek(english-gregorian)

献花(0)
+1
(本文系网络学习天...首藏)