王朝网络
分享
 
 
 

PHP中文函数连载(二)

王朝php·作者佚名  2006-12-16
宽屏版  字体: |||超大  

函数apache_lookup_uri()

描述:

Perform a partial request for the specified URI and return all info about it,This performs a partial request for a URI. It goes just far enough to obtain all the important information about the given resource and returns this information in a class. The properties of the returned class are:

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_uri mtime、request_time

函数apache_note()

描述:

Get and set apache request notes,apache_note() is an Apache-specific function which gets and sets values in a request's notes table. If called with one argument, it returns the current value of note note_name . If called with two arguments, it sets the value of note note_name to note_value and returns the previous value of note note_name .

函数getallheaders()

描述:

Fetch all HTTP request headers(取得所有HTTP头部请求)

例子:

$headers = getallheaders();

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

echo "$header: $value

\n";

}

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

注:此函数只支持APACHE下的PHP

函数virtual()

描述:

virtual() is an Apache-specific function which is equivalent to in mod_include. It performs an Apache sub-request. It is useful for including CGI scripts or .shtml files, or anything else that you would parse through Apache. Note that for a CGI script, the script must generate valid CGI headers. At the minimum that means it must generate a Content-type header.

数组函数

函数array()

描述:

建立一个数组

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

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

Example 1. array() example

$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()

描述:

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

int array_walk (array arr, string func);

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

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

Example 1. array_walk() example

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

function test_alter( $item1 ) { $item1 = 'bogus'; }

function test_print( $item2 ) { echo "$item2

\n"; }

array_walk( $fruits, 'test_print' );

array_walk( $fruits, 'test_alter' );

array_walk( $fruits, 'test_print' );

函数arsort()

描述:

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

void arsort (array array);

This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. Example 1. 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";

}

This example would display: fruits[a] = orange fruits[d] = lemon fruits[b] = banana fruits[c] = apple The fruits have been sorted in reverse alphabetical order, and the index associated with each element has been maintained.

函数asort()

描述:

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

void asort (array array);

This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. Example 1. 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";

}

This example would display: fruits[c] = apple fruits[b] = banana fruits[d] = lemon fruits[a] = orange The fruits have been sorted in alphabetical order, and the index associated with each element has been maintained.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有