Increasing nesting function calls limit
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.
Solution 1:
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.
Solution 2:
Do you have Zend, IonCube, or xDebug installed? If so, that is probably where you are getting this error from.
I ran into this a few years ago, and it ended up being Zend putting that limit there, not PHP. Of course removing it will let you go past the 100 iterations, but you will eventually hit the memory limits.
Solution 3:
Personally I would suggest this is an error as opposed to a setting that needs adjusting. In my code it was because I had a class that had the same name as a library within one of my controllers and it seemed to trip it up.
Output errors and see where this is being triggered.