Php recursive functions: the ultimate solution to the return value of php recursive functions
In php recursive functions, there is often a problem that recursive functions do not return values. how can we correctly process the returned values in php recursion? what can we do if php recursive functions do not return values, you can refer to the example analysis in this article. I. php recursive function return values Example 1: Sample code:Function test ($ I) {$ I-= 4; if ($ I <3) {return $ I;} else { Test ($ I );}} Echo test (30 ).""; Note that there is a problem in the else in the above code. if the condition $ I <3, all the functions return $ I will not return the value. Example 2: modify the php recursive function: Sample code:Function test ($ I) {$ I-= 4; if ($ I <3) {return $ I;} else { Return test ($ I );}} Echo test (30 ).""; II. php recursive function return value problems |