时间:2021-07-01 10:21:17 帮助过:2人阅读
- <br>$a = 0; <br>function iterate() { <br>global $a; <br>if( $a < 10 ) <br>recur(); <br>echo $a . ", "; <br>} <br>function recur() { <br>global $a; <br>$a++; <br>// how did I get here? <br>echo "\n\n\n”; <br>debug_print_backtrace(); <br>if( $a < 10 ) <br>iterate(); <br>} <br>iterate(); <br># OUTPUT: <br>#0 recur() called at [C:\htdocs\php_stuff\index.php:8] <br>#1 iterate() called at [C:\htdocs\php_stuff\index.php:25] <br>#0 recur() called at [C:\htdocs\php_stuff\index.php:8] <br>#1 iterate() called at [C:\htdocs\php_stuff\index.php:21] <br>#2 recur() called at [C:\htdocs\php_stuff\index.php:8] <br>#3 iterate() called at [C:\htdocs\php_stuff\index.php:25] <br>#0 recur() called at [C:\htdocs\php_stuff\index.php:8] <br>#1 iterate() called at [C:\htdocs\php_stuff\index.php:21] <br>#2 recur() called at [C:\htdocs\php_stuff\index.php:8] <br>#3 iterate() called at [C:\htdocs\php_stuff\index.php:21] <br>#4 recur() called at [C:\htdocs\php_stuff\index.php:8] <br>#5 iterate() called at [C:\htdocs\php_stuff\index.php:25] <br> <br><strong>7. metaphone()</strong> <br>这个函数返回单词的metaphone值,相同读音的单词具有相同的metaphone值,也就是说这个函数可以帮你判断两个单词的读音是否相同。不过对中文就无效了。。。 <br><strong>8. natsort()</strong> <br>natsort()能将一个数组以自然排序法进行排列,直接看个例子吧: <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br>$items = array( <br>“100 apples”, “5 apples”, “110 apples”, “55 apples” <br>); <br>// normal sorting: <br>sort($items); <br>print_r($items); <br># Outputs: <br># Array <br># ( <br># [0] => 100 apples <br># [1] => 110 apples <br># [2] => 5 apples <br># [3] => 55 apples <br># ) <br>natsort($items); <br>print_r($items); <br># Outputs: <br># Array <br># ( <br># [2] => 5 apples <br># [3] => 55 apples <br># [0] => 100 apples <br># [1] => 110 apples <br># ) <br> <br><strong>9. levenshtein()</strong> <br>Levenshtein()告诉你两个单词之间的“距离”。它告诉你如果想把一个单词变成另一个单词,需要插入、替换和删除多少字母。 <br>看个例子吧: <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br>$dictionary = array( <br>“php”, “javascript”, “css” <br>); <br>$word = “japhp”; <br>$best_match = $dictionary[0]; <br>$match_value = levenshtein($dictionary[0], $word); <br>foreach($dictionary as $w) { <br>$value = levenshtein($word, $w); <br>if( $value < $match_value ) { <br>$best_match = $w; <br>$match_value = $value; <br>} <br>} <br>echo “Did you mean the ‘$best_match' category?”; <br> <br><strong>10. glob()</strong> <br>glob()会让你觉得用opendir(), readdir()和closedir()来寻找文件非常蠢。 <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br>foreach (glob(“*.php”) as $file) <br>echo “$file\n”; <br></li><li> </li><li> </li></ol></pre></li></ol></pre></li></ol></pre>