2

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?

Charles
  • 50,943
  • 13
  • 104
  • 142
Doug T.
  • 64,223
  • 27
  • 138
  • 202

3 Answers3

10

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
  • 91,582
  • 23
  • 169
  • 153
4

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.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
0

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 González
  • 142,137
  • 41
  • 261
  • 360