PHP recursive function in the use of return when you encounter can not be properly returned to the desired situation, let me give an example to illustrate the
PHP recursive function in the use of return when you can not correctly returned to the desired situation, if you do not understand the reasons, it is difficult to find the wrong, the following specific examples to illustrate it: The code is as follows: function test ($i) {$i-=4; if ($i <3) {return $i; }else{test ($i); } echotest (30); This code does not seem to be a problem, if you do not run an estimate you will not think he has any problems, in time to run up to find that there are problems you do not necessarily know where there is a problem, but in fact this function else inside is problematic. The result of executing in this code is no return value. So while satisfying the condition $i <3 return $i The entire function still does not returns a value. Therefore, the above PHP recursive function can be modified as follows (more PHP tutorials please visit the Code Home): The code is as follows: function test ($i) {$i-=4; if ($i <3) {return $i; }else{return test ($i);//Add returns, let function back value} echotest (30);