防止网站上的错误消息

时间:2013-02-01 08:49:01

标签: php cakephp

我正在使用第三方API,它使用

trigger_error function

关于错误。

反过来将在网站上显示。什么是防止在网站上显示此类错误的更好方法?

4 个答案:

答案 0 :(得分:0)

将它置于PHP文件之上

error_reporting(0);
ini_set('display_errors', 0);

答案 1 :(得分:0)

与@Dainis Abols一样,您可以使用每个文档头部的error_reporting()函数调用关闭错误报告,也可以将其放在所有文档中通常使用的包含文件中。最有效的方法是在你的php.ini文件中更改它,但是你要将error_reporting改为0。

答案 2 :(得分:0)

如果您需要阻止所有错误,则意味着您无需在脚本或第三方API中显示任何错误,您可以使用

error_reporting(0);
ini_set('display_errors', 0);

如果您需要在特定代码行中防止某些错误,请使用该行的@ infront来抑制错误

请参阅此处http://us3.php.net/manual/en/language.operators.errorcontrol.php

答案 3 :(得分:0)

如果您正在使用cakephp,请在Config / core.php中将调试更改为0

/**
 * CakePHP Debug Level:
 *
 * Production Mode:
 *  0: No error messages, errors, or warnings shown. Flash messages redirect.
 *
 * Development Mode:
 *  1: Errors and warnings shown, model caches refreshed, flash messages halted.
 *  2: As in 1, but also with full debug messages and SQL output.
 *
 * In production mode, flash messages redirect after a time interval.
 * In development mode, you need to click the flash message to continue.
 */
    Configure::write('debug', 0);
相关问题