简体   繁体   English

如何禁用E_STRICT

[英]How to disable E_STRICT

I need to turn off E_STRICT. 我需要关闭E_STRICT。 I have error_reporting = E_ALL & ~E_STRICT in my php.ini but it seems to be ignored. 我的php.ini中有error_reporting = E_ALL&〜E_STRICT,但似乎被忽略了。 I tried this in my code: 我在我的代码中试过这个:

ini_set('error_reporting', E_NOTICE);

Nothing! 没有!

Please help. 请帮忙。

try this. 试试这个。

error_reporting(E_ALL ^ E_STRICT);

This will report all errors except E_STRICT 这将报告除E_STRICT之外的所有错误

If you've got your own error handler (search your code for set_error_handler ), then the error_reporting config 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_types指定的错误类型,标准PHP错误处理程序是完全被绕过的,除非回调函数返回FALSE。 error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. error_reporting()设置将不起作用 ,无论如何都将调用您的错误处理程序 - 但是您仍然可以读取error_reporting的当前值并采取适当的操作。 Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator. 特别值得注意的是,如果导致错误的语句由@ 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_STRICT from the error_reporting config could fail, if the error occurs in the same file where error_reporting(...) (or ini_set('error_reporting, ...') ) is called. 如果错误发生在调用error_reporting(...) (或ini_set('error_reporting, ...') )的同一文件中,则从error_reporting配置中删除E_STRICT可能会失败。

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. 其他的事情:大多数框架都有自己的配置文件来解决生产软件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. 开发软件,他们有自己的做事方式,所以我会从那里开始....看看文档,看看是否有任何你需要改变...它可能是一个超级简单的改变最有可能的配置文件。

I was installing CMS Made simple when I ran into that error but here is how I over came it: 当我遇到这个错误时,我正在安装CMS简单但这是我过去的方式:

1) Open your php.ini file using any of your favorite editors;notepad, notepad++ or dreamweaver. 1)使用您喜欢的任何编辑器打开您的php.ini文件;记事本,记事本++或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 Stuff但是找一个这种设置;

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 ";" error_reporting = E_ALL ,这里的值没有“;” is what matters so I just cleared it to: 是重要的,所以我只是清除它:

error_reporting = (delete) and removed the E_ALL , and saved the file, I restarted all the services, and everything worked fine. error_reporting =(删除)并删除了E_ALL ,并保存了文件,我重新启动了所有服务,一切正常。 Hope that works for you too!. 希望对你也有用!

error_reporting(E_ALL & ~E_STRICT);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM