php 5 与 php 4 向后兼容的程度如何?

发布于 2024-07-26 02:32:24 字数 127 浏览 5 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

垂暮老矣 2024-08-02 02:32:24

查看从 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.

柠檬 2024-08-02 02:32:24

根据我的经验,痛苦的主要来源是代码依赖于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文