Solved

Upgrading code from PHP4 to 5.4+

Posted on 2013-01-07
3
240 Views
Last Modified: 2013-01-10
Hi there, I have a customer who have a few customer developed sections on their website that was many years ago now and worked fine running on PHP4.  Their hosting provider now let them know that PHP4 will be unsupported soon so they'd have to upgrade to at least 5.4.  We did a quick test and it does break most if on PHP 5.4.

I did a couple PHP projects about 10 years ago now so I can help myself but I thought I'd here for some hints of the most important things to change so it will work for 5.4 or later. I found this - http://php.net/manual/en/migration5.incompatible.php - but their site doesn't do anything fancy, advice for obvious things to check would be very handy thanks!
0
Comment
Question by:ebooyens
3 Comments
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 38751894
There are some serious changes at each step in PHP 5.1, 5.2, 5.3, and 5.4, not just from PHP 4 to 5.  Each step gets less and less tolerant of programming errors.  In particular, undeclared variables and array indexes are not ignored anymore.

A site I am working on right now failed when moving from PHP 4 to PHP 5.2 because it was using the old PHP GET ($HTTP_GET_VARS) and POST ($HTTP_POST_VARS) variables and the developer had substituted 'preg_match' for 'ereg' without modifying the regex strings.
0
 
LVL 33

Accepted Solution

by:
Slick812 earned 250 total points
ID: 38752511
I looked at the PHP manual page "Backward Incompatible Changes" that you gave, it gives very many of things to consider for a Change to the newer PHP version. Not sure what else you may be looking for as advice to change, seems like it covers it.
Unfortunately for me, I had the task of updating an old php coded site. I found that I would spend less time, if I used (copy and paste, include) code I have done for other projects that gave same or similar PHP results for the database and Page display required, , ,  NOT referring to the old code except to get file names, sever locations, etc, instead of going line by line in the old code and trying to FIX it. That old code was so outdated and slack, that even if corrected to working, it was not a good thing.
Also updating the site to newer HTML standards for size (1600x900, mobile) and "Look" (dynamic-HTML, Div, span, overlap, javascript) was not in the old site code. So might you start from scratch, and use more modern methods of php and DHTML, and have less time used, if you have some of your own coding that does what the pages need to do? ? ?
0
 
LVL 4

Author Closing Comment

by:ebooyens
ID: 38765918
Thanks both, very helpful, I've started looking at the code now so trying to figure out how bad it's going to be!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now