search

Home  >  Q&A  >  body text

Problem using recursive functions on tp3.2, please help me

111.png222.png

The left side of the picture is the code, and the right side is the running result. I execute the aaa() function, which executes the kissom() function three times, but why are the results printed the second and third times the same, and there is only one line? It should be a static problem. When executing the second and third times, $ count is updated. But this function can be executed if it is not placed in tp, but cannot be executed in the tp framework. Is there anyone who can give me some guidance?

phpcn_u1546phpcn_u15462705 days ago1137

reply all(1)I'll reply

  • phpcn_u1546

    phpcn_u15462017-08-27 16:50:51

    Modify it, I changed the above if condition to $count<5, I forgot about it. Is there a great god?

    reply
    0
  • ringa_lee

    After you execute kissom for the first time in the aaa method, $count finally equals 4. Because your if condition is <5, it will not run if it equals 5, so the next two calls are both 5.

    ringa_lee · 2017-08-27 22:41:38
  • Cancelreply