Solutions to the problem of return values from PHP recursive functions, as well as some points to pay attention to when using return statements in PHP recursive functions to return values, and correctly handle the return values of PHP recursive functions to make the code more robust.
The return value problem of php recursive function Example: Copy code Code example:There is a problem in else in the above code. The test executed here has no return value. Therefore, although the condition $i Make the following modifications to the above php recursive function: Copy code Code example:Notes on return values in php recursive functions When using return in a PHP recursive function, you will encounter situations where the desired value cannot be returned correctly. If you don’t understand the reason, it will be difficult to find the error. Example: Copy code Code example: function test($i){ $i-=4; if($iIn fact, there is a problem in the else of this function. The result of execution in this code has no return value. So even if the condition $i Copy code Code example: function test($i){ $i-=4; if($i |