php 如何禁用 E_STRICT
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2851004/
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
How to disable E_STRICT
提问by rtacconi
I need to turn off E_STRICT. I have error_reporting = E_ALL & ~E_STRICT in my php.ini but it seems to be ignored. I tried this in my code:
我需要关闭 E_STRICT。我的 php.ini 中有 error_reporting = E_ALL & ~E_STRICT 但它似乎被忽略了。我在我的代码中试过这个:
ini_set('error_reporting', E_NOTICE);
Nothing!
没有!
Please help.
请帮忙。
采纳答案by Dinesh Nagar
try this.
尝试这个。
error_reporting(E_ALL ^ E_STRICT);
This will report all errors except E_STRICT
这将报告除 E_STRICT 之外的所有错误
回答by stofl
If you've got your own error handler (search your code for set_error_handler), then the error_reportingconfig value will be ignored:
如果您有自己的错误处理程序(在您的代码中搜索set_error_handler),那么error_reporting配置值将被忽略:
It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effectand your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator.
重要的是要记住,除非回调函数返回 FALSE,否则对于 error_types 指定的错误类型完全绕过标准 PHP 错误处理程序。error_reporting() 设置将无效,并且无论如何都会调用您的错误处理程序 - 但是您仍然可以读取 error_reporting 的当前值并采取适当的行动。需要特别注意的是,如果导致错误的语句是由@error-control 操作符添加的,则该值将为 0。
http://php.net/manual/en/function.set-error-handler.php
http://php.net/manual/en/function.set-error-handler.php
Also removing E_STRICTfrom the error_reportingconfig could fail, if the error occurs in the same file where error_reporting(...)(or ini_set('error_reporting, ...')) is called.
如果错误发生在调用(或)的同一文件中,E_STRICT则从error_reporting配置中删除也可能会失败。error_reporting(...)ini_set('error_reporting, ...')
回答by luke
You mentioned you're using a framework (would be good to know which one) anyway you can add something like this on the very first index.php:
你提到你正在使用一个框架(最好知道哪个)无论如何你可以在第一个 index.php 上添加这样的东西:
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('display_errors', 'On');
But make sure you're on the first index.php that gets called, meaning the very first in the stack, for certain framework that would save you some pain.
但是请确保您在第一个被调用的 index.php 上,这意味着在堆栈中的第一个,对于某些框架,这可以为您节省一些痛苦。
Other thing: most of the frameworks have their own config file to address production software VS. development software and they have their own way of doing things, so I would start from there....have a look at the docs and find out if there's anything there you need to change...it could be a super simple change on a config file most likely.
另一件事:大多数框架都有自己的配置文件来解决生产软件 VS。开发软件,他们有自己的做事方式,所以我会从那里开始......看看文档,看看是否有任何你需要改变的地方......这可能是一个超级简单的改变最有可能的配置文件。
回答by Kawuma Abel
I was installing CMS Made simple when I ran into that error but here is how I over came it:
当我遇到该错误时,我正在安装 CMS Made simple,但这是我解决它的方法:
1) Open your php.ini file using any of your favorite editors;notepad, notepad++ or dreamweaver.
1) 使用任何您喜欢的编辑器打开您的 php.ini 文件;notepad、notepad++ 或 Dreamweaver。
2) Press ctrl+f to fire up the find Dialog Box.
2) 按 ctrl+f 启动查找对话框。
3) Type E_STRICT and click ok to jump you to the E_STRICT Line, there several E_STRICT Stuff but look for one with this kind of setting;
3) 输入 E_STRICT 并点击确定跳转到 E_STRICT 行,有几个 E_STRICT 的东西,但找一个有这种设置的;
Common Values:
共同价值观:
E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.)
E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices)
E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.)
Default Value: E_ALL & ~E_NOTICE
Development Value: E_ALL | E_STRICT
Production Value: E_ALL & ~E_DEPRECATED
http://php.net/error-reporting
error_reporting= E_ALL, here the value with out the ";" is what matters so I just cleared it to:
error_reporting= E_ALL,这里是没有“;”的值 重要的是,所以我只是将其清除为:
error_reporting= (delete) and removed the E_ALL, and saved the file, I restarted all the services, and everything worked fine. Hope that works for you too!.
error_reporting= (delete) 并删除了E_ALL,并保存了文件,我重新启动了所有服务,一切正常。希望对你也有用!
回答by Bogdan
error_reporting(E_ALL & ~E_STRICT);

