colap Posted June 20, 2011 Share Posted June 20, 2011 Hi, How can i convert php4 code to php5 code? Is there any script to covert? I tried to install php4tophp5.exe but it doesn't install. A project is written in php4 using CMS. Now i need to convert it. Can anyone help me to figure it out? Thanks. Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/ Share on other sites More sharing options...
gristoi Posted June 20, 2011 Share Posted June 20, 2011 The best way to do this is really going to be the manual approach. Put your CMS on a server with PHP5 and turn on full error checking: ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); The work through the warnings and errors, you will get a lot more warnings than fatal errors. work through and remove the depreciated functions and replace them with their php5 counterpart for each warning given. Shouldnt take more than a few hours Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232170 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 20, 2011 Share Posted June 20, 2011 Hi, How can i convert php4 code to php5 code? Is there any script to covert? I tried to install php4tophp5.exe but it doesn't install. A project is written in php4 using CMS. Now i need to convert it. Can anyone help me to figure it out? Thanks. http://www.php.net/ChangeLog-5.php More than likely, you're not going to need to change any code... maybe bits and pieces at best. Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232171 Share on other sites More sharing options...
colap Posted June 20, 2011 Author Share Posted June 20, 2011 It's depricated, how can i convert it into php5 code? $_VERSION =& new version(); Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232177 Share on other sites More sharing options...
Alex Posted June 20, 2011 Share Posted June 20, 2011 It's depricated, how can i convert it into php5 code? $_VERSION =& new version(); $_VERSION = new version(); I'm not sure that will give you an error, but in PHP 5 objects are passed by reference by default so you don't need the &. Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232180 Share on other sites More sharing options...
gristoi Posted June 20, 2011 Share Posted June 20, 2011 PHP 4 passes objects by value, php 5 passes by reference, so remove the & Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232181 Share on other sites More sharing options...
colap Posted June 20, 2011 Author Share Posted June 20, 2011 It's php4 code. Deprecated: Function split() is deprecated in offline.php $iso = split( '=', _ISO ); How can i convert it to php5 code? Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232185 Share on other sites More sharing options...
KevinM1 Posted June 20, 2011 Share Posted June 20, 2011 It's php4 code. Deprecated: Function split() is deprecated in offline.php $iso = split( '=', _ISO ); How can i convert it to php5 code? Use preg_split. Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232187 Share on other sites More sharing options...
gristoi Posted June 20, 2011 Share Posted June 20, 2011 for every deprecated function you hit just google: PHP5 version of deprecated (whatever the function name is) Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232189 Share on other sites More sharing options...
colap Posted June 20, 2011 Author Share Posted June 20, 2011 The best way to do this is really going to be the manual approach. Put your CMS on a server with PHP5 and turn on full error checking: ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); The work through the warnings and errors, you will get a lot more warnings than fatal errors. work through and remove the depreciated functions and replace them with their php5 counterpart for each warning given. Shouldnt take more than a few hours Where would i put these lines? ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232190 Share on other sites More sharing options...
trq Posted June 20, 2011 Share Posted June 20, 2011 At the top of any scripts. Preferably somewhere where it will be included into every page. Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232191 Share on other sites More sharing options...
gristoi Posted June 20, 2011 Share Posted June 20, 2011 at the very top of your php scripts. <?php ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); // rest of script. note that you said this was a cms which could indicate ( and dont quote me lol) that it may be using the (MVC Pattern). which means that everything is routed through one page (usually the index.php). If this is the case then u only need to add it into the index page Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232195 Share on other sites More sharing options...
trq Posted June 20, 2011 Share Posted June 20, 2011 You are NOT coming to this board for every error in this CMS. Read this: http://www.php.net/manual/en/migration5.php Link to comment https://forums.phpfreaks.com/topic/239879-how-can-i-convert-php4-code-to-php5-code/#findComment-1232197 Share on other sites More sharing options...
Recommended Posts