Jump to content

php 4.4.0 to php 5.2


DoctorX

Recommended Posts

Hi,

 

We have a site which was developed back in 2003 and is build on php 4.4, infact that is the ONLY version that keeps the site running right.  I want to now upgrade our server and having a hard time building software packages which are so old to work with the new hardware which is now available.  I want to convert the code to php 5.2.x and would like to know what is the best way?  is it just something simple or am I just asking for trouble?  Is there a good tool available that can change/upgrade the code for me?

 

We would also like to make this site multi-lingual, what can be done about that?

 

BTW I am also running MySQL version 4.1.20.

 

 

|X|

Link to comment
https://forums.phpfreaks.com/topic/105368-php-440-to-php-52/
Share on other sites

That's about it. There is no way of knowing how easy or hard it will be without just trying it.

 

As for multilingual sites - this is how I do it.

 

1) I create files for each language. For example index_en.php and index_jp.php

2) In these files, I define constants like this:

 

index_en.php

define ("_INDEX_", "index");

index_jp.php

define ("_INDEX_", "indekkusu");

 

You will notice that the define name is the same for both English and Japanese - _INDEX_. I use this format of an underscore tagged on the front and the back out of a person preference. It lets me know that the text comes from the language files. Its by no means required though, and you can use whatever format you want.

 

3) At the top of each page, I check to see what the language is set to (you can set it with a cookie, or a config document, or settings in the users control panel or however you want). I then use that language to include applicable language document.

 

index.php

$language = $_COOKIE['language'];
require_once("index_{$language}.php");

 

4) In the  same document (in this case index.php), for any place I would use the word 'index', I use _INDEX_.

 

index.php

echo _INDEX_

 

So now, if the cookie for language is set to 'en', then index.php will output 'index'. If the cookie is set to 'jp', index.php will output 'indekkusu'.

Link to comment
https://forums.phpfreaks.com/topic/105368-php-440-to-php-52/#findComment-539656
Share on other sites

There are very few "backward" incompatible differences between php4 and php5. Even php4 OOP syntax works under php5.

 

http://www.php.net/manual/en/faq.migration5.php

http://www.php.net/manual/en/migration5.php

 

You are more likely to find configuration differences if your code was developed on a system that was not using recommended php.ini settings.

 

You can find the general things in your code that you will need to fix (short open tags, register globals...) by comparing the php.ini settings from your php4 system and the php5 system.

 

Turning on full php error_reporting (set it to E_ALL) and setting display_errors on in your php.ini or a .htaccess file will get php to help you find problems with your code, such as program variables that are no longer being magically populated due to register globals.

 

A number of old and depreciated features and functions are being eliminated in php6. If you are upgrading your code, you might as well make it php6 compatible at the same time - http://derickrethans.nl/files/meeting-notes.html#cleanup-of-functionality

Link to comment
https://forums.phpfreaks.com/topic/105368-php-440-to-php-52/#findComment-539667
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.