2017-06-03 19 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]選項來做到這一點。 –