[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Upgrading code from PHP4 to 5.4+

Posted on 2013-01-07
3
Medium Priority
?
261 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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 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 34

Accepted Solution

by:
Slick812 earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 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