Increasing nesting function calls limit

barbushin picture barbushin · Nov 27, 2010 · Viewed 106.9k times · Source

There is one very bad limit in PHP: if you call some function a1() that calls a2(), that calls a3... so when a99() will call a100() you will see

Fatal error: Maximum function nesting level of '100' reached, aborting!

Is there any way to increase the limit of 100 nesting calls to 500 or 10000?

This is critical for me because I'm developing an event-based system with a lot of callbacks.

Answer

netcoder picture netcoder · Nov 27, 2010

This error message comes specifically from the XDebug extension. PHP itself does not have a function nesting limit. Change the setting in your php.ini:

xdebug.max_nesting_level = 200

or in your PHP code:

ini_set('xdebug.max_nesting_level', 200);

As for if you really need to change it (i.e.: if there's a alternative solution to a recursive function), I can't tell without the code.