无法在 OpenCart (PHP) 中禁用错误报告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16935473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't disable error reporting in OpenCart (PHP)
提问by colmde
I can't seem to disable error reporting in PHP - I have tried everything but "Notice" errors are still displayed.
我似乎无法禁用 PHP 中的错误报告 - 我已经尝试了所有方法,但仍然显示“通知”错误。
My php.ini has
我的 php.ini 有
display_errors = Off;
error_reporting = 0;
My .htaccess has
我的 .htaccess 有
php_value error_reporting 0
And my script has
我的脚本有
ini_set('display_errors', 'Off');
ini_set('log_errors', 1);
ini_set('error_reporting', 0);
ini_set('display_startup_errors', 'Off');
php_info();
echo $my_undefined_var;
The php_info() output confirms that display_errors and error_reporting are indeed off and 0, and yet I still get a notice,
php_info() 输出确认 display_errors 和 error_reporting 确实关闭且为 0,但我仍然收到通知,
Notice: Undefined variable: my_undefined_var in /my/site/path/index.php?blahblah...
注意:未定义变量:my_undefined_var in /my/site/path/index.php?blahblah...
Note this is an OpenCart website (and my change is in the Admin section). I have tried creating a test php script in the same directory as index.php and it's fine.
请注意,这是一个 OpenCart 网站(我的更改在管理部分)。我尝试在 index.php 所在的目录中创建一个测试 php 脚本,这很好。
Is there anything else that could be overriding the error_reporting(0)
?
还有什么可以覆盖的error_reporting(0)
吗?
I've done a grep of the entire site to find and disable all mentions of the error_reporting and display_errors but to no avail.
我已经完成了整个站点的 grep 以查找和禁用所有提到的 error_reporting 和 display_errors 但无济于事。
回答by random_user_name
There is a setting within the OpenCart dashboard that allows you to turn on (or off) error reporting and logging.
OpenCart 仪表板中有一个设置,允许您打开(或关闭)错误报告和日志记录。
- Log into your dashboard
- In the menu, go to "System" and select "Settings"
- In the list of stores, click "Edit" for your store
- Click the "Server" tab.
- Scroll down, and there's two settings:
a. Log Errors - set this as desired
b. Display Errors - set this to "No"
- 登录您的仪表板
- 在菜单中,转到“系统”并选择“设置”
- 在商店列表中,单击您商店的“编辑”
- 单击“服务器”选项卡。
- 向下滚动,并且有两个设置:
一。日志错误 - 根据需要进行设置
b. 显示错误 - 将此设置为“否”
回答by zergussino
As @colmde already pointed OpenCart uses custom error_handler.
正如@colmde 已经指出 OpenCart 使用自定义 error_handler。
You can turn error displaying off without any code edits (especially OpenCart core files) via:
您可以通过以下方式关闭错误显示而无需任何代码编辑(尤其是 OpenCart 核心文件):
Admin->System->Settings->[edit your configured store]->Server->Display Errors
Admin->System->Settings->[edit your configured store]->Server->Display Errors
[EDIT] You can do the same by running following query against OpenCart database:
[编辑] 您可以通过对 OpenCart 数据库运行以下查询来执行相同的操作:
update setting set `value`= 1 where `key` = 'config_error_display'
回答by colmde
OpenCart uses the set_error_handler()
function which causes it to override the error_reporting(0)
.
OpenCart 使用set_error_handler()
导致它覆盖error_reporting(0)
.
Removing this fixed my problem.
删除它解决了我的问题。
回答by Abhinav bhardwaj
you can simply use
你可以简单地使用
ini_set('display_errors', 0);
on system/startup.php
在系统/startup.php
回答by R. Mavlyanoff
True way in OpenCart.
OpenCart 中的真实方式。
$this->config->set('config_error_display', 0);
$this->processAction(); // it throws ugly warning
I've tested in the controllerof my module. Just to turn off showing errors before your code. It affects only current session (perhaps even current page). It doesn't affect the DB!
我已经在我的模块的控制器中进行了测试。只是为了在您的代码之前关闭显示错误。它只影响当前会话(甚至可能是当前页面)。它不影响数据库!
回答by Victor Bel
for me helped: //error_reporting(E_ALL);
对我有帮助://error_reporting(E_ALL);
in file startup.php
在文件 startup.php 中