Solved

Upgrading code from PHP4 to 5.4+

Posted on 2013-01-07
3
243 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 34

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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