Upgrading my php4 script to php5

They have: 1 posts

Joined: Jun 2009

Hi all,

my current sit is running on php4 and I would like upgrade it to php5, how would I go about implementing the necessary changes to the my script in order to do this.

My developer as recently gone AWAL and would really appreciate any assistance regarding this.

greg's picture

He has: 1,581 posts

Joined: Nov 2005

Welcome to TWF Smiling

Without seeing ALL the code it's hard to say. There are some functions (etc) that will have worked in PHP4 but no longer work in PHP5 (and of course vice versa but that doesn't apply to you).

"In general" there is likely to be none to very little you will need to change.
The best way forward for you is to FTP the entire site to a non-public server that is running PHP5, make sure screen error reporting is ON and set to show absolutely everything, including notices and warnings.

Then go through the entire site and check everything works. If a function (etc) is specific to versions prior to PHP5, then it "should" put a message on the screen, with something such as:

Unknown function {function name} {file and line where function is used}

If you can't change the on screen error reporting, you will have to run through the site and then check the error log.

Either log or on screen would tell you the function or whatever is causing the error and which file it is used in and even the line number in that file.

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

just a note of reference, Greg was referring to this statement:

error_reporting(E_ALL);

One thing to note, you may get a bunch of notices that a variable was used before it was defined. While I prefer to never have this happen, PHP unlike some other languages will auto create a variable and set it to NULL the first time it is called if not already.

However, do NOT just ignore them, check to make sure they are not variables which used to be automatically created off of things such as POST/GET/SESSION values. Some sites on PHP4 still use this either on older versions of PHP4, or later ones with the settings changed.

If you come across a variable that is being used that you can't seem to find where it was defined (and from the code it appears it should be already), look for a form value, or session value by the same name.

While making this change, IMO it is best to go through all the code and implement security and error checking.

-Greg

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.