php函数案例,php函数连续调用实例分析

php函数连续调用实例分析

recur();

echo $a . “, “;

}

function recur() {

global $a;

$a++;

// how did I get here?

echo “\n\n\n”;

debug_print_backtrace();

if( $a < 10 )

iterate();

}

iterate();

# OUTPUT:

#0 recur() called at [C:\htdocs\php_stuff\index.php:8]

#1 iterate() called at [C:\htdocs\php_stuff\index.php:25]

#0 recur() called at [C:\htdocs\php_stuff\index.php:8]

#1 iterate() called at [C:\htdocs\php_stuff\index.php:21]

#2 recur() called at [C:\htdocs\php_stuff\index.php:8]

#3 iterate() called at [C:\htdocs\php_stuff\index.php:25]

#0 recur() called at [C:\htdocs\php_stuff\index.php:8]

#1 iterate() called at [C:\htdocs\php_stuff\index.php:21]

#2 recur() called at [C:\htdocs\php_stuff\index.php:8]

#3 iterate() called at [C:\htdocs\php_stuff\index.php:21]

#4 recur() called at [C:\htdocs\php_stuff\index.php:8]

#5 iterate() called at [C:\htdocs\php_stuff\index.php:25]

7. metaphone()

这个函数返回单词的metaphone值,相同读音的单词具有相同的metaphone值,也就是说这个函数可以帮你判断两个单词的读音是否 相同。

8. natsort()

natsort()能将一个数组以自然排序法 进行排列,直接看个例子吧:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

$items = array(

“100 apples”, “5 apples”, “110 apples”, “55 apples”

);

// normal sorting:

sort($items);

print_r($items);

# Outputs:

# Array

# (

# [0] => 100 apples

# [1] => 110 apples

# [2] => 5 apples

# [3] => 55 apples

# )

natsort($items);

print_r($items);

# Outputs:

# Array

# (

# [2] => 5 apples

# [3] => 55 apples

# [0] => 100 apples

# [1] => 110 apples

# )

9. levenshtein()

Levenshtein()告诉你两个单词之间的“距离”。它告诉你如果想把一个单词变成另一个单词,需要插入、替换和删除多少字母。

看个例子吧:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

$dictionary = array(

“php”, “javascript”, “css”

);

$word = “japhp”;

$best_match = $dictionary[0];

$match_value = levenshtein($dictionary[0], $word);

foreach($dictionary as $w) {

$value = levenshtein($word, $w);

if( $value < $match_value ) {

$best_match = $w;

$match_value = $value;

}

}

echo “Did you mean the ‘$best_match' category?”;

10. glob()

glob()会让你觉得用 opendir(), readdir()和closedir()来寻找文件非常蠢。

?

1

2

foreach (glob(“*.php”) as $file)

echo “$file\n”;

【php函数连续调用实例分析】相关文章:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值