Home  >  Article  >  Backend Development  >  When calling a recursive function in a loop, is the nested number 100 cumulative?

When calling a recursive function in a loop, is the nested number 100 cumulative?

WBOY
WBOYOriginal
2016-12-01 00:56:48925browse

I have a foreach function that calls a recursive function to obtain a subset. There are 36 records in total. When I get to the 16th record, I get an error

<code>Maximum function nesting level of '100' reached, aborting! in </code>

This shouldn’t be an endless loop, right?

When calling a recursive function in a loop, is the nested number 100 cumulative?

When calling a recursive function in a loop, is the nested number 100 cumulative?

Code pictures

Reply content:

I have a foreach function that calls a recursive function to obtain a subset. There are 36 records in total. When I get to the 16th record, I get an error

<code>Maximum function nesting level of '100' reached, aborting! in </code>

This shouldn’t be an endless loop, right?

When calling a recursive function in a loop, is the nested number 100 cumulative?

When calling a recursive function in a loop, is the nested number 100 cumulative?

Code pictures

This is the limit of the entire call stack. You can call the debug_backtrace method to get the current stack depth

http://php.net/manual/en/func...

<code>function test() {
    echo count(debug_backtrace()) . "\n";
}

function test2() {
    test();
}

test(); //输出1
test2(); //输出2
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn