Blogger Information
Blog 263
fans 3
comment 2
visits 113272
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
递归函数
福哥的博客
Original
926 people have browsed it
<?php
function test($n){
    echo $n.'&nbsp;';
    if($n>0){
        test($n-1);//自己内部调用自己,即 递归函数
    }else{
        echo '<-->';
    }
    echo $n.'&nbsp;';
}
test(3);
/*
 * 死循环了,所以在使用递归的时候要注意避免这种情况!
function test($n){
    echo $n.'&nbsp;';
    test($n-1);
}
test(3);
*/
?>

递归函数执行流程.png

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post