nuttycoder Posted February 7, 2009 Share Posted February 7, 2009 With my work servers going from php 4 to 5 in the next few weeks am concerned I'll be spending much of my time at work making changes to their old sites to make them work in PHP 5 What are the differences from 4 to 5 and is there anything I should be aware of? most of the sites were built with procedural coding. Apart from the systems I have built I can see there being some transition problems so can anyone shed any light on the main changes they know of when moving from 4 to 5? Quote Link to comment https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2009 Share Posted February 7, 2009 There are very few incompatible differences between php4 and php5 - http://www.php.net/manual/en/migration5.php Most php4 code will work as is under php5, given the same php.ini configuration. However, there are a number of depreciated features that have been turned off (and are removed in php6) and you need to account for any differences between your existing php4 php.ini settings and the current recommend php.ini settings. Quote Link to comment https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/#findComment-756874 Share on other sites More sharing options...
.josh Posted February 7, 2009 Share Posted February 7, 2009 The only thing significant that php5 gets rid of is register globals. Basically that means for instance, if you have a form and a text input field named 'foobar', with register_globals on, you can access it simply by using $foobar, instead of through the $_POST or $_REQUEST array. With register_globals off (or removed), you would have to access it from $_POST['foobar'] or $_REQUEST['foobar']. Same thing with variables coming from the url string (the GET method) from links or via form GET method. Instead of being able to use $foobar you would have to use $_GET['foobar'] or $_REQUEST['foobar']. PHP4 already has register globals off by default, so chances are, you aren't even using them. So unless your script is making use of register globals, you shouldn't really need to change anything. php5 mostly just fixed some bugs and added a bunch of new features. A lot of things have been deprecated though...meaning they will still work, but they have been flagged for eventual removal (some things even as early as php6), so going from php4 or php5 to php6 might be more problematic for you. edit: hmm...I guess I must have read something wrong at some point in time...looks like register globals are still around in php5 and still disabled by default. They are being removed in php6. Quote Link to comment https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/#findComment-756877 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 Thanks for that, yeah I don't use register globals to no worries there, by the looks of things the sites shouldn't be affected only time will tell. Quote Link to comment https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/#findComment-756878 Share on other sites More sharing options...
.josh Posted February 7, 2009 Share Posted February 7, 2009 Yeah, since you said that the code is all procedural, it really shouldn't be a problem. PHP5 was mostly all about new OOP features. If you follow the link PFM gave, you will find what is backwards incompatible. I have no idea what your scripts look like or what they do or anything, but looking at that link, most everything on there is a pretty easy thing to fix. Quote Link to comment https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/#findComment-756885 Share on other sites More sharing options...
nuttycoder Posted February 7, 2009 Author Share Posted February 7, 2009 the ones I have built I tested on a php5 server so I know they work, I should have said that in my first post. Quote Link to comment https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/#findComment-756894 Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2009 Share Posted February 7, 2009 Depending on where you got your php5 distribution and who configured it, your php.ini might not be using the recommend settings. The major items in the current recommend php.ini (from the Windows distribution) are - short_open_tag = Off allow_call_time_pass_reference = Off * output_buffering = 4096 (which I don't agree with, it should be Off for a live server) error_reporting = E_ALL display_errors = Off log_errors = On register_globals = Off * register_long_arrays = Off * register_argc_argv = Off magic_quotes_gpc = Off * session.bug_compat_42 = 0 * * - indicates things removed in php6 Quote Link to comment https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/#findComment-756901 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.