在 PHP 5.4 中禁用严格标准

Disabling Strict Standards in PHP 5.4(在 PHP 5.4 中禁用严格标准)
本文介绍了在 PHP 5.4 中禁用严格标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我目前在 php 5.4 上运行一个站点,在此之前我在 5.3.8 上运行我的站点.不幸的是,php 5.4 结合了 E_ALLE_STRICT,这意味着我之前对 error_reporting 的设置现在不起作用.我以前的值是 E_ALL &~E_NOTICE &~E_STRICT 我应该一次只启用一个值吗?

I'm currently running a site on php 5.4, prior to this I was running my site on 5.3.8. Unfortunately, php 5.4 combines E_ALL and E_STRICT, which means that my previous setting for error_reporting does not work now. My previous value was E_ALL & ~E_NOTICE & ~E_STRICT Should I just enable values one at a time?

我有太多错误,而且文件包含太多代码需要我修复.

I have far too many errors and the files contain too much code for me to fix.

推荐答案

正如评论者所说,最佳选项是修复错误,但在时间或知识有限的情况下,这并不总是可行的.在您的 php.ini 更改

As the commenters have stated the best option is to fix the errors, but with limited time or knowledge, that's not always possible. In your php.ini change

error_reporting = E_ALL

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

如果您无权访问 php.ini,您可以将其放入您的 .htaccess 文件中:

If you don't have access to the php.ini, you can potentially put this in your .htaccess file:

php_value error_reporting 30711

这是 E_ALL 值 (32767) 以及删除 E_STRICT (2048) 和 E_NOTICE (8) 值.

This is the E_ALL value (32767) and the removing the E_STRICT (2048) and E_NOTICE (8) values.

如果您无权访问 .htaccess 文件或它未启用,您可能需要将它放在从浏览器调用加载的任何脚本的 PHP 部分的顶部:

If you don't have access to the .htaccess file or it's not enabled, you'll probably need to put this at the top of the PHP section of any script that gets loaded from a browser call:

error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);

其中之一应该可以帮助您使用该软件.通知和严格的内容是问题或潜在问题的指标,您可能会发现某些代码在 PHP 5.4 中无法正常工作.

One of those should help you be able to use the software. The notices and strict stuff are indicators of problems or potential problems though and you may find some of the code is not working correctly in PHP 5.4.

这篇关于在 PHP 5.4 中禁用严格标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Why can#39;t I update data in an array with foreach loop?(为什么我不能用 foreach 循环更新数组中的数据?)
Foreach for arrays inside of an array(Foreach 用于数组内的数组)
PHP array get next key/value in foreach()(PHP 数组在 foreach() 中获取下一个键/值)
Using preg_match on a multidimensional array to return key values arrays(在多维数组上使用 preg_match 返回键值数组)
php foreach as key, every two number as a group(php foreach 为key,每两个数字为一组)
Treat a PHP class that implements Iterator as an array(将实现 Iterator 的 PHP 类视为数组)