Maximum function nesting level of '100' reached

Once in a while I have this problem. I have a recursive function that builds a DOM three of threaded replies (like a typical mailing list), so if a reply has a reply,it will recurse, passing “this” message as an argument, and the same deal repeats. This works well except when sometimes, very rarely the threaded conversation goes over 100 levels deep, in which case the script dies with this message “Maximum function nesting level of ‘100’ reached”

I searched and could not find a way to set this limit higher in php. Does not look like it can be changed in php.ini file.

Have anyone figured out a way to fix this?

Thanks. I think the whole problem with this error was caused by xdebug. It turns out that it’s the xdebug that has this max value of 100 nested functions. increasing xdebug.max_nesting_level to 200 solved my problem.

Two solutions:

  1. Re-write your recursive function such that 100 nested calls can never happen
  2. (Install Xdebug and) use the xdebug.max_nesting_level php.ini option to raise the limit