Solved

Upgrading code from PHP4 to 5.4+

Posted on 2013-01-07
3
241 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 83

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHPStorm debugging issues 1 25
php string masking 4 29
How to set a countdown by not using the PC time in PHP 36 45
php function to remove a file 26 11
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.

867 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