The confusion of the "bible" recursive problem think of 555 also no solution to the day ...
This post was last edited by Iamsai on 2013-09-24 21:00:08
$str = ' Hello ';
Reverse_i ($STR);
function Reverse_i ($STR)
{
if (strlen ($STR) >0)
{
Reverse_i (substr ($STR, 1));
}
Echo substr ($str, 0, 1);
Return
}
?>
Please look at my question:
The output of this program is the reverse output olleh.
Through the Loop body reverse_i (substr ($STR, 1)); Operation of the statement Hello Ello llo lo o
When the character length is ==0, Echo substr ($str, 0, 1); Output O.
What value is returned from the return statement? Is it back to line fourth? What is the subsequent order of execution? Who can help me analyze and analyze? Thank you, Hero!
Share to:
------Solution--------------------
if (strlen ($STR) >0)
?? {???
???? Reverse_i (substr ($STR, 1)); This is a recursive call
<---back to here
??}
?? Echo?substr ($str, 0, 1);
?? Return