Does PHP optimize tail recursion?

后端 未结 3 1571
不知归路
不知归路 2020-12-03 02:58

I wrote a small piece of code that I believe should have succeeded if tail recursion was optimized, however it blew up the stack. Should I conclude PHP does not optimize tai

3条回答
  •  借酒劲吻你
    2020-12-03 03:28

    It is possible to call recursive functions in PHP. However avoid recursive function/method calls with over 100-200 recursion levels as it can smash the stack and cause a termination of the current script.

    http://php.net/manual/en/functions.user-defined.php

    Seems like a safe assumption that it's not.

提交回复
热议问题