Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/144227-moving-from-php-4-to-5/
Share on other sites

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.

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.

 

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.