How to get current recursion level in a PHP function

前端 未结 5 1892
灰色年华
灰色年华 2021-01-18 05:20

How to get current recursion level in a PHP function ? I mean, is there any \"magical\" (or eventually normal) function like this :

function doSomething($thi         


        
5条回答
  •  滥情空心
    2021-01-18 05:36

    In java you can inspect the call stack. I think you can do the same in php:

    debug-backtrace Is this the one you are looking for?

    Since php does not optimize recursion with tail calls this should tel you the depth of the recursion.

提交回复
热议问题