为何lumen框架中的undefined index错误会抛出异常?

<?php
    $a = array();
    $b = $a['test'];
?>

以上代码单独执行时只会报:PHP Notice: Undefined index: test in /private/var/folders/lr/hbwptx4s1017kl_hlr4d9b4r0000gn/T/CodeRunner/Untitled.php on line 3

但是在lumen框架中却会抛出一个ErrorException异常:

(1/1) ErrorException
Undefined index: test

in ExampleController.php (line 23)
at Application->Laravel\Lumen\Concerns\{closure}(8, 'Undefined index: test', '/Users/kai/work/api/app/Http/Controllers/ExampleController.php', 23, array())
in ExampleController.php (line 23)
at ExampleController->testOrder()
at call_user_func_array(array(object(ExampleController), 'testOrder'), array())
in BoundMethod.php (line 29)
达令说
浏览 908回答 1
1回答

慕姐8265434

因为设置了: error_reporting(-1);,然后用set_error_handler处理错误,在处理的时候抛出异常。 相关代码在IlluminateFoundationBootstrapHandleExceptions::bootstrap
打开App,查看更多内容
随时随地看视频慕课网APP