Solutions for PHP recursive return values. We are using this to start writing :? Phpfunctiontest ($ I) {$ I-4; if ($ i3) {return $ I;} else {test ($ I) ;}} echotest (30 );? This code looks okay. In fact, we are using e.This is the beginning of writing:
- <? Php
- Function test ($ I)
- {
- $ I-= 4;
- If ($ I< 3)
- {
- Return $ I;
- }
- Else
- {
- Test ($ I );
- }
- }
- Echo test (30 );
- ?>
This code seems to be okay. In fact, there is a problem in else. The test executed here does not return a value. Therefore, even if the condition $ I <3 is met, the return $ I function does not return a value. The above PHP recursive return value function is modified as follows:
- <? Php
- Function test ($ I)
- {
- $ I-= 4;
- If ($ I <3)
- {
- Return $ I;
- }
- Else
- {
- Return test ($ I); // add return to let the function return values.
- }
- }
- Echo test (30 );
- ?>
The above code example is the specific solution to the problem of PHP recursive return values.
Begin :? Php functiontest ($ I) {$ I-= 4; if ($ I 3) {return $ I;} else {test ($ I );}} echotest (30 );? This code seems to be okay. In fact, there are e...