Solved

Upgrading code from PHP4 to 5.4+

Posted on 2013-01-07
3
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

737 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