【发布时间】:2014-12-01 14:04:11
【问题描述】:
我两次遇到这个错误,每次都花了将近 30 分钟来调试它。我希望它会对某人有所帮助,因为我在互联网上找到的只是关闭 xDebug 的解决方案。
PHP 致命错误:已达到“100”的最大函数嵌套级别,正在中止!
【问题讨论】:
我两次遇到这个错误,每次都花了将近 30 分钟来调试它。我希望它会对某人有所帮助,因为我在互联网上找到的只是关闭 xDebug 的解决方案。
PHP 致命错误:已达到“100”的最大函数嵌套级别,正在中止!
【问题讨论】:
问题是由默认 xdebug.max_nesting_level 100 引起的。
通过在 Laravel 5.1 中的 bootstrap/autoload.php 中添加以下行
ini_set('xdebug.max_nesting_level', 120);
.........
define('LARAVEL_START', microtime(true));
这个回答对我有帮助。
【讨论】:
这就是我的问题。
我有一个服务类,它是 codeigniter 中的库。像这样在里面有一个函数。
class PaymentService {
private $CI;
public function __construct() {
$this->CI =& get_instance();
}
public function procss(){
// lots of Ci referencing here ...
}
我的控制器如下:
$this->load->library('PaymentService');
$this->process_(); // see I got his wrong instead it should be like below
$this->Payment_service->process(); //the library class name
然后我不断收到超出错误消息。但我确实禁用了 XDebug 但没有帮助。无论如何,请检查您的类名或代码是否正确调用函数。
【讨论】:
这发生在我身上,因为我不小心将两个类相互注入了。
class Foo(Bar $bar){}
class Bar(Foo $foo){}
$bar = new Bar(new Foo(new bar(new Foo(...))));
之所以没有看到,是因为 Laravel IOC。所以实例化一个类的语法类似于:
$bar = new Bar(Foo $foo);
【讨论】: