增加嵌套函数调用限制 [英] Increasing nesting function calls limit

查看:85
本文介绍了增加嵌套函数调用限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP有一个非常糟糕的限制:如果您调用某个调用a2()的函数a1(),又调用了a3 ...,那么当a99()将调用a100()时,您会看到

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

致命错误:函数最大嵌套级别达到'100',正在中止!

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

有什么方法可以将100个嵌套调用的限制增加到500个或10000个?

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.

推荐答案

此错误消息特别来自XDebug扩展. PHP本身没有函数嵌套限制.更改php.ini中的设置:

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

或在您的PHP代码中:

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.

这篇关于增加嵌套函数调用限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆