<?php
/*
* php递归函数的用法
* 你玩过吗?
* 下面开始玩一玩
*/
//自己调自己就是回调 实现了一个垒加2垒减2的效果
class digui{
public function index($number){
if($number>0) {
echo $number," ";
$this->index($number-2); //自己调自己就是回调
}
}
public function unindex($number1){
if($number1<=10){
echo $number1," ";
$this->unindex($number1+2);
}
}
}
$obj = new digui();
$obj ->index(10);
echo "<br />";
$obj ->index(9);
echo "<br />";
$obj ->unindex(1);
echo "<br />";
$obj ->unindex(2);递归函数你玩懂了吗?,布布扣,bubuko.com
递归函数你玩懂了吗?
原文:http://blog.csdn.net/qq1355541448/article/details/38312799