简体   繁体   English

将php4 / mysql4迁移到php5 / mysql5:预期的php问题?

[英]Migrating php4/mysql4 to php5/mysql5: expected php issues?

I have a legacy web application php4/mysql4 (MyISAM, db contains some cms, some user data, some calendar application). 我有一个遗留的Web应用程序php4 / mysql4(MyISAM,数据库包含一些cms,一些用户数据,一些日历应用程序)。 Now I am going to migrate to a new server with php5/mysql5. 现在,我将使用php5 / mysql5迁移到新服务器。

What are the typical php issues in such a migration scenary (php, sql queries, anything)? 在这样的迁移场景中,典型的php问题是什么(php,sql查询等)?

I've heard that the function parameter passing changed, call-by-reference / call-by-value. 我听说传递的函数参数已更改,即按引用调用/按值调用。 Can you give an example or explain? 你能举一个例子或解释吗?

Anything else I should be aware of? 我还有什么需要注意的吗?

(The mysql issues are covered in a different question: Migrating php4/mysql4 to php5/mysql5: switch to InnoDB? ) (MySQL问题涵盖在另一个问题中:将php4 / mysql4迁移到php5 / mysql5:切换到InnoDB吗?

我认为最好的迁移帮助来自PHP本身。

Most of the PHP 4/5 compatibility issues are two things: 大多数PHP 4/5兼容性问题是两件事:

  • new reserved words 新的保留字
  • new class/object backend 新的类/对象后端

Most v4 code will run just fine in v5. 大多数v4代码在v5中都能正常运行。 Where you are likely to run up against problems is code that depends on the limitations of v4's class model or takes advantage of v4's reference quirks. 您可能会遇到问题的地方是取决于v4的类模型的限制或利用v4的参考怪癖的代码。 But most people don't code up against those limits (I have - that's why I know they're there). 但是大多数人并没有超出这些限制(我有-这就是为什么我知道他们在那里的原因)。

If you are stuck with the class/object limits, you can run the Zend engine in a "v1" mode which makes the classes and objects behave like in v4. 如果您坚持使用类/对象限制,则可以在“ v1”模式下运行Zend引擎,这会使类和对象的行为类似于v4。 This is documented. 记录在案。

I'm in the middle of a migration and I'm finding lots of aliasing problems. 我正在迁移中,并且发现很多别名问题。

If you want to have a clean code, then you'll need to find the proper solution to your specific snippet. 如果您想要一个干净的代码,则需要为您的特定代码段找到合适的解决方案。 If cleanness is not that important, you might find this function really useful: 如果清洁不是那么重要,那么您可能会发现此功能确实有用:

function php4_clone($object) {
    if (version_compare(phpversion(), '5.0') < 0) {
        return $object;
    } else {
        return @clone($object);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM