学习 PHP中文函数.docx
- 文档编号:25538848
- 上传时间:2023-06-09
- 格式:DOCX
- 页数:17
- 大小:19.75KB
学习 PHP中文函数.docx
《学习 PHP中文函数.docx》由会员分享,可在线阅读,更多相关《学习 PHP中文函数.docx(17页珍藏版)》请在冰豆网上搜索。
学习PHP中文函数
学习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);
Thisfunctionsortsanarraysuchthatarrayindicesmaintaintheircorrelationwiththearrayelementstheyareatedwith.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
Employeename | Salary |
---|---|
id=$id\">$name | \n"."$salary | \n"."
函数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)=e
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学习 PHP中文函数 PHP 中文 函数