php 5 与 php 4 向后兼容的程度如何?
我使用 php 4 编写的代码库。我想完成将代码升级到 php 5(我的主机提供的最新版本)的过程。 我想知道是否有其他人经历过类似的升级经历,并且可以分享有哪些陷阱/陷阱,我的代码中必须更改哪些内容,两个版本之间不向后兼容的内容是什么?
I work on a code base written in php 4. I'd like to go through the process of upgrading the code to php 5 (the latest version my host provides). I'm wondering if anyone else has gone through a similar upgrade experience and can share what gotchas/pitfalls there are, what has to change in my code, what is not backwards compatible between the two versions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看从 PHP 4 迁移到 5 的指南。 尽管存在一些向后不兼容的更改<,但您现有的 PHP 4 代码大部分应该仍然可以工作/a>.
Take a look at the guide for migrating from PHP 4 to 5. Your existing PHP 4 code should mostly still work, though there are some backward-incompatible changes.
查看从 PHP 4 迁移到 PHP 5.0.x 文档页面。
最重要的部分是向后不兼容更改。
只要您在以前的应用程序中没有使用类和对象,array_merge 可能是您可能遇到的唯一主要问题。
不要启用
zend.ze1_compatibility_mode
配置变量。Check out the Migrating from PHP 4 to PHP 5.0.x documentation page.
The most important section is Backward Incompatible Changes.
AS long as you didn't use classes and objects in your previous application, array_merge is probably the only major problem you can encounter.
DO NOT enable the
zend.ze1_compatibility_mode
configuration variable.根据我的经验,痛苦的主要来源是代码依赖于 PHP 4 中已弃用的功能。这些通常是:
没有任何搜索和替换可以帮助您识别此类内容。 删除它会导致大量难以发现的故障。 保留它们会导致代码难以维护。 设置激进的 error_reporting 级别会导致无穷无尽的通知。
In my experience, the main source of pain is when the code relies on features that were already deprecated in PHP 4. Those are typically:
There's no search and replace that can help you to identify such stuff. Removing it leads to tons of hard-to-spot failures. Keeping them leads to unmaintainable code. Setting an aggressive error_reporting level leads to an endless flood of notices.