views:

498

answers:

3

Hello everyone,

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?

+6  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.

Daniel Vandersluis
+1 for beating me to posting those exact links.
Ben S
+3  A: 

Chck 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.

Simone Carletti
A: 

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.

Álvaro G. Vicario