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.
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:
or in your PHP code:
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.
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.
Yes, it's possible to increase the value of
xdebug.max_nesting_level
inphp.ini
. If you done this don't forget to restart the apache server:But in most cases this error is not caused by that, but by many redirections or errors on your page.
So just switch to debug if you have one or watch your logs.
If you're using XDebug (with XAMPP, for example), you can set nesting level by adding this to
php.ini
file (I would suggest to put at the bottom of file):This will set to 500 limit but it could more if needed. Only link to XDebug file
php_xdebug.dll
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.