2017-06-03 16 views
0

如何隐藏它在浏览器中显示的框架错误? 我搜索application.config,应用程序module.config试图更改标志和模板,但没有效果。如何隐藏ZendFramework3提供的浏览器错误?

如何在浏览器中隐藏错误,但将它们留在控制台中?

作为服务器我现在使用在php5.6服务器建立

'view_manager' => [ 
    'display_not_found_reason' => true, 
    'display_exceptions'  => false, 
    'doctype'     => 'HTML5', 
    'not_found_template'  => 'error/404', 
    'exception_template'  => 'error/index', 
    'template_map' => [ 
     'layout/layout'   => __DIR__ . '/../view/layout/layout.phtml', 
     'application/index/index' => __DIR__ . '/../view/application/index/index.phtml', 
     'error/404'    => __DIR__ . '/../view/error/custom_404.phtml', 
     'error/index'    => __DIR__ . '/../view/error/index.phtml', 
    ], 
    'template_path_stack' => [ 
     __DIR__ . '/../view', 
    ], 
], 

回答

1

有两种方法可以做到这一点,因为Zend公司是一个PHP框架,这样你就可以用PHP代码或与Zend设置隐藏文件。

1)核心PHP。

error_reporting(E_ALL); 
ini_set('display_errors', true); 

PHP error settings

2)Zend的更改设置,按您的要求false将隐藏自己的错误。

/*in your module.config.php */ 
'view_manager' => array(
    'display_not_found_reason' => true, 
    'display_exceptions' => true, 
    'doctype' => 'HTML5', 
    'not_found_template' => 'error/404', 
    'exception_template' => 'error/index', 
    'template_map' => array(
     'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 
     '/index/index' => __DIR__ . '/../view/user/index/index.phtml', 
     'error/404' => __DIR__ . '/../view/error/404.phtml', 
     'error/index' => __DIR__ . '/../view/error/index.phtml', 
    ), 
    'template_path_stack' => array(
     __DIR__ . '/../view', 
    ), 
), 
+0

谢谢你的回答,但第二个不起作用。我不知道为什么,但当我更改'display_exceptions'的标志为true或false时,结果保持不变 – NotAWizzard

+0

我不确定为什么自从您将其设置为false以来出现此错误,则需要在您的末端进行调试..你可以使用[1]选项来做到这一点。 –