在禁用过时功能警告的情况下更新到PHP 5.3 [英] Updating to PHP 5.3 with deprecated functions warning disabled

查看:81
本文介绍了在禁用过时功能警告的情况下更新到PHP 5.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常希望将我们的许多服务器更新为PHP 5.3.这将为Zend Framework 2和明显的性能更新做好准备.不幸的是,我在这些服务器上拥有大量的遗留代码,这些遗留代码会及时修复,但在迁移之前无法全部修复.我正在考虑更新,但是在除少数开发站点之外的所有站点上禁用了不推荐使用的函数错误,在这些站点上,我可以开始通过更新旧代码进行工作.

I'm very keen to update a number of our servers to PHP 5.3. This would be in readiness for Zend Framework 2 and also for the apparent performance updates. Unfortunately, i have large amounts of legacy code on these servers which in time will be fixed, but cannot all be fixed before the migration. I'm considering updating but disabling the deprecated function error on all but a few development sites where i can begin to work through updating old code.

error_reporting(E_ALL ^ E_DEPRECATED);

这是一个不好的主意吗?

Is there any fundamental reason why this would be a bad idea?

推荐答案

如果您尚未阅读迁移指南,重点放在向后不兼容的更改已删除的扩展名.

If you haven't already you should read the migration guide with particular focus on Backward Incompatible Changes and Removed Extensions.

您遇到的问题要比弃用问题大.忽略E_DEPRECATED是不够的.由于更改不兼容,因此还会出现其他类型的错误,甚至可能是更糟糕的意外行为.

You have bigger issues than deprecation. Ignoring E_DEPRECATED will not suffice. Because of the incompatible changes there will also be other type of errors or, maybe, even worse, unexpected behaviors.

这是一个简单的例子:

<?php
function goto($line){
    echo $line;
}
goto(7);
?>

此代码在PHP 5.2.x中可以正常工作并输出7,但在PHP 5.3.x中将为您提供解析错误.

This code will work fine and output 7 in PHP 5.2.x but will give you a parse error in PHP 5.3.x.

您需要做的是获取该指南中的每一项,并检查代码并在需要的地方进行更新.为了使其更快,您可以在第一阶段忽略已弃用的功能 ,而只禁用E_DEPRECATED的错误报告,但是您不能假设移植到另一个主要版本时只会得到一些无害的警告. PHP分支.

What you need to do is take each item in that guide and check your code and update where needed. To make this faster you could ignore the deprecated functionality in a first phase and just disable error reporting for E_DEPRECATED, but you can't assume that you will only get some harmless warnings when porting to another major PHP branch.

也不要忘记您的黑客,并尽快解决不推荐使用的问题.

Also don't forget about your hack and fix the deprecated issues as soon as possible.

关于,
阿林

注意:我试图从实际的角度回答问题,所以请不要告诉我忽略警告是不好的.我知道,但我也知道时间不是无限的资源.

这篇关于在禁用过时功能警告的情况下更新到PHP 5.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆