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

霸气de小男生 提交于 2019-12-24 00:36:00

问题


I have a legacy web application php4/mysql4 (MyISAM, db contains some cms, some user data, some calendar application). Now I am going to migrate to a new server with php5/mysql5.

What are the typical php issues in such a migration scenary (php, sql queries, anything)?

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?)


回答1:


Most of the PHP 4/5 compatibility issues are two things:

  • new reserved words
  • new class/object backend

Most v4 code will run just fine in 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. 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. This is documented.




回答2:


I think the best migration help is from the PHP guys themselves.




回答3:


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);
    }
}


来源:https://stackoverflow.com/questions/745806/migrating-php4-mysql4-to-php5-mysql5-expected-php-issues

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!