Upgrading to PHP 5

After upgrading to PHP 5 there were some issues on my web server, which were easily fixed once they arose. Otherwise, everything went smoothly.

Here’s a quick overview of the details  I had when upgrading from PHP 4.3 to 5.1

PHP

register_globals

Version 5 of PHP turns off Magic Quotes and register globals by default. register_globals was defaulted to OFF since version 4.2.0 but I had to turn it on to accommodate some older sites that I began hosting and didn’t initially develop. So when the upgrade took place these sites had some issues, which I had to fix. Really it just consisted of going through these pages and adjusting code to get the variable data properly rather than as if register_globals was turned on.

Magic Quotes

These have also been turned off by default since 4.3 and will be totally removed in PHP 6 so they shouldn’t be used at all any way. Magic quotes would simply add backslashes accordingly as data was sent to the server, with them turned off it would break some database queries, and cause warnings and other variables problems. The problem is that programmers need to be more careful of the data they are receiving and validate the data before it is being used.

Both register_globals and Magic Quotes were implemented in PHP to help beginners who were learning to program in PHP or new to programming in general. One thing I noticed about the upgrade was that neither of the problems I encountered were major, but also that they weren’t related to the actual upgrade to version 5, as they both should have been taken care of already. It brings up the discussion of a good programmer versus a bad/lazy programmer. Most of the sites that had any issues, and the few that had major issues were ones that I had taken over and was hosting but didn’t initially create. The sites were not built so long ago that there was an excuse for using both register_globals and magic quotes, and it shows that having programming standards is important, and that keeping up to date with programming trends and upgrades to the programming language are very important. I’m glad I caught this before I upgraded to verion 6 when I possibly would have had a much harder time solving the problem.

Having them both enabled created performance and security implications, and after upgrading to version 5, I’m glad that there issues were raised again so I could fix them and move forward with both settings disabled server-wide.

One Comment on “Upgrading to PHP 5”

  1. 2718.us blog - Note to Self: Validate Input before using it in SQL Queries Says:

    [...] and just like I’ve been going through and fixing register_globals dependence… As I read here, Both register_globals and Magic Quotes were implemented in PHP to help beginners who were learning [...]

Comment