I need to setup my PHP script at the top to disable error reporting for strict standards.

我需要在頂部設置PHP腳本,以禁用嚴格標准的錯誤報告。

Can anybody help ?

有人能幫忙嗎?

7 个解决方案

#1

178

Do you want to disable error reporting, or just prevent the user from seeing it? It’s usually a good idea to log errors, even on a production site.

您想要禁用錯誤報告,還是僅僅防止用戶看到它?記錄錯誤通常是個好主意,即使是在生產站點上。

# in your PHP code:

ini_set('display_errors', '0'); # don't show any errors...

error_reporting(E_ALL | E_STRICT); # ...but do log them

They will be logged to your standard system log, or use the error_log directive to specify exactly where you want errors to go.

它們將被記錄到您的標准系統日志中,或者使用error_log指令來精確地指定錯誤的去向。

#2

88

For no errors.

沒有錯誤。

error_reporting(0);

error_reporting(0);

or for just not strict

或者因為不嚴格

error_reporting(E_ALL ^ E_STRICT);

error_reporting(E_ALL ^代碼);

and if you ever want to display all errors again, use

如果您想再次顯示所有錯誤,請使用

error_reporting(-1);

error_reporting(1);

#3

29

All above solutions are correct. But, when we are talking about a normal PHP application, they have to included in every page, that it requires. A way to solve this, is through .htaccess at root folder. Just to hide the errors. [Put one of the followling lines in the file]

以上的解決方案都是正確的。但是,當我們討論普通的PHP應用程序時,它們必須包含在它需要的每個頁面中。解決這個問題的一種方法是通過根文件夾的.htaccess。只是為了隱藏錯誤。[在文件中加入以下一行]

php_flag display_errors off

Or

php_value display_errors 0

Next, to set the error reporting

接下來,設置錯誤報告

php_value error_reporting 30719

If you are wondering how the value 30719 came, E_ALL (32767), E_STRICT (2048) are actually constant that hold numeric value and (32767 - 2048 = 30719)

如果您想知道值30719是怎么來的,E_ALL (32767), E_STRICT(2048)實際上是保持數值的常量(32767 - 2048 = 30719)

#4

9

The default value of error_reporting flag is E_ALL & ~E_NOTICE if not set in php.ini. But in some installation (particularly installations targeting development environments) has E_ALL | E_STRICT set as value of this flag (this is the recommended value during development). In some cases, specially when you'll want to run some open source projects, that was developed prior to PHP 5.3 era and not yet updated with best practices defined by PHP 5.3, in your development environment, you'll probably run into getting some messages like you are getting. The best way to cope up on this situation, is to set only E_ALL as the value of error_reporting flag, either in php.ini or in code (probably in a front-controller like index.php in web-root as follows:

error_reporting標志的默認值是E_ALL & ~E_NOTICE(如果不在php.ini中設置的話)。但是在某些安裝(特別是針對開發環境的安裝)中,E_ALL | E_STRICT設置為這個標志的值(這是開發過程中推薦的值)。在某些情況下,特別是當您想要運行一些開放源碼項目時,這些項目是在PHP 5.3之前開發的,並且還沒有使用PHP 5.3定義的最佳實踐進行更新,在您的開發環境中,您可能會遇到一些您正在獲得的消息。處理這種情況的最佳方法是,在php中只將E_ALL設置為error_reporting標志的值。ini或代碼(可能在前端控制器如索引中)。web-root中的php如下:

if(defined('E_STRICT')){

error_reporting(E_ALL);

}

#5

7

In php.ini set :

在php中。ini設置:

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

#6

4

WordPress

WordPress

If you work in the wordpress environment, Wordpress sets the error level in file wp-includes/load.php in function wp_debug_mode(). So you have to change the level AFTER this function has been called ( in a file not checked into git so that's development only ), or either modify directly the error_reporting() call

如果您在wordpress環境中工作,wordpress會在文件wp-include /load中設置錯誤級別。php在wp_debug_mode()函數。因此,您必須在調用該函數之后(在未檢入git的文件中,這只是開發)更改級別,或者直接修改error_reporting()調用

#7

2

I didn't see an answer that's clean and suitable for production-ready software, so here it goes:

我沒有看到一個干凈的、適合生產用的軟件的答案,所以它是這樣的:

/*

* Get current error_reporting value,

* so that we don't lose preferences set in php.ini and .htaccess

* and accidently reenable message types disabled in those.

*

* If you want to disable e.g. E_STRICT on a global level,

* use php.ini (or .htaccess for folder-level)

*/

$old_error_reporting = error_reporting();

/*

* Disable E_STRICT on top of current error_reporting.

*

* Note: do NOT use ^ for disabling error message types,

* as ^ will re-ENABLE the message type if it happens to be disabled already!

*/

error_reporting($old_error_reporting & ~E_STRICT);

// code that should not emit E_STRICT messages goes here

/*

* Optional, depending on if/what code comes after.

* Restore old settings.

*/

error_reporting($old_error_reporting);

php 屏蔽 strict standards,PHP 5禁用嚴格的標准錯誤相关推荐

  1. php 屏蔽 strict standards,PHP Strict Standards:问题解决

    cmseasy3.9版本 安装 提示: PHP Strict Standards:Declaration of announcement::getcols() should be compatible ...

  2. php5.3.0以上出现Strict Standards错误

    在运行PHP软件时,若是碰到类似的错误,"Strict Standards",不是错误,而是PHP5.3和之前的版本不太兼容.5.3之后的版本规定声明须要在应用之前. 批改php. ...

  3. alipay.php on line 85,Ecshop报错:Strict Standards: Redefining already defined constructor for class...

    今天小编在使用ecshop建站的时候遇到了一个问题,报错提示: Strict Standards: Redefining already defined constructor for class a ...

  4. strict standards php报错,Bigcommerce:PHP版本升级错误解决办法_PHP教程

    报错内容一:Strict Standards: Declaration of....should be compatible with ..... Strict Standards: Declarat ...

  5. ecshop后台出现Strict Standards: Only variables should be passed by refin /var/www·····

    Strict Standards: Only variables should be passed by reference in /var/www/wordpress/ecshop/includes ...

  6. ecshop Strict standards: Only variables should be passed by reference in flashplay.php on line 181

    全部错误提示:Strict standards: Only variables should be passed by reference in **\admin\flashplay.php on l ...

  7. js控制禁用退格键回到上一个页面

    js控制禁用退格键回到上一个页面 我们在真实的项目开发中经常会使用JS 对键盘上的一些按键进行禁用,常见的比如说退格键(backspace/ 后退键),我在一个项目中就遇到过在页面编辑的时候禁用掉退格 ...

  8. js禁用退格键(BackSpace)

    js禁用退格键(BackSpace) 在TextBox中设置 contentEditable="false" 或者 ReadOnly="true" 那么该文本框 ...

  9. 服务器屏蔽了无线网卡,树莓派永久禁用无线网卡

    之前树莓派一直用的无线网卡,不过更新系统,安装软件,传输文件都实在太慢了,所以我找了一根网线把树莓派连在路由器上面.这样感觉好多了还是有线稳定啊.因为基本不再用无线,所以就准备把无线网卡禁用掉. 首先 ...

最新文章

  1. php常用的搜索引擎,常用搜索引擎高级命令有哪些
  2. (二十)java多线程之ScheduledThreadPoolExecutor
  3. LRU(Least Recently Used)算法的理解
  4. Heartbeats
  5. 最短路径之--floyd算法--多源最短路径
  6. MySQL【环境搭建 03】腾讯云 Linux 环境踩坑 loading shared libraries: libnuma.so.1 + quit without updating PID file
  7. [蓝桥杯][算法提高VIP]合并石子(区间dp+平行四边形优化)
  8. 【IOS】获取wifi名称 (即SSID)
  9. plsql设置oracle11g,数据库oracle11G,如何通过plsql查询表空间大小,如何通过PLSQL把一个表空间的大小设置成自动扩展...
  10. 关于java中main方法为什么必须是静态的
  11. rgb颜色查询工具_《我的眼睛–图灵识别》第三章:基础:颜色识别
  12. Magnet for mac(专业窗口辅助工具)支持m1
  13. go语言中错误处理方式
  14. 软件测试——图书管理系统的测试计划书
  15. 【MATLAB统计分析与应用100例】案例015:matlab读取Excel数据,进行值聚类分析
  16. 华为 GaussDB 首席架构师 武新离职,出任易鲸捷CEO
  17. java根据http url下载图片
  18. html 复制文本 点击复制按钮
  19. centos查询php目录大小,Linux CentOS下找到大于10M 小于100M的文件列出来的命令
  20. 扫拖地机器人预留_进阶规划,扫拖一体,小瓦扫地机器人规划版重度体验

热门文章

  1. python壁纸数据抓取_70行python代码实现壁纸批量下载
  2. ps界面为啥突然变大了_PS简单3步带你完成包装效果「09」
  3. 荣耀8xmax鸿蒙,荣耀8X Max是什么屏幕?
  4. python+vue+elementui校园运动场地体育器材管理系统
  5. 2022浙江最新高级消防设施操作员模拟试题题库及答案
  6. 第十章 Golang面向对象编程(上)
  7. Android仿虾米音乐播放器之MediaPlayer使用
  8. android webview加载不出来,【新手有关问题】Android浏览器中WebView加载不出网页
  9. 获取文件夹所有的文件
  10. Vue超实用案例1:使用setTimeout实现延迟执行代码