"Bible" recursive questions about the problem of thinking about a day 555 also no solution.

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.