Php5 migration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Php5 migration

Post by lettie_dude »

My host provider has just decided to migrate to php5 from 4 on various servers.

An effect of this has been for several of my sites to stop working properly. Various issues are:

Session folder path could not be found and access was denied to write to the folder. (rectified by host)

$HTTP_POST_VARS stopped working causing me to go through it site and replace it with $_POST there was no notification that this would happen!

Checking variables with empty i.e. if(empty($var)) seems not to work as desired now.

Also SESSION variables are not being created or not being registered to be displayed on redirect pages.

Eveything on the sites was working correctly before migration.

Can anyone make any suggestions as to what the hosts have to implement to correct this? (whether they will is another matter!)

Also is there anything else I need to consider over and above the documentation available at php.net?

Any help much appreciated.

Cheers
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Php5 migration

Post by Ambush Commander »

You must be using really old code!
Checking variables with empty i.e. if(empty($var)) seems not to work as desired now.
Objects with no properties are now NOT considered empty.
Also SESSION variables are not being created or not being registered to be displayed on redirect pages.
We'll need some code about this.

Also see: http://docs.php.net/manual/en/migration5.php
User avatar
Sekka
Forum Commoner
Posts: 91
Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK

Re: Php5 migration

Post by Sekka »

It may not seem like it now, but your host has done a good thing moving from PHP 4 to 5. PHP 5 has been out for 6 years now (maybe 5), and as such, most people should be programming in this version.

If you were programming correctly in PHP 4, you shouldn't have too many problems moving from PHP 4 to 5. Some of your code may be really old, e.g. $HTTP_POST_VARS, and as you said it is just a case of replacing them with the newer forms, e.g. $_POST.

As for your sessions, how are you using them? This is how I use sessions in PHP 5 as an example,

Code: Select all

// Start the session
session_start ();
 
// Set something in the session
$_SESSION['something'] = "Who there?";
 
// Using something from the session
echo "Bob says " . $_SESSION['something'];
 
// Removing something from the session
unset ($_SESSION['something']);
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Re: Php5 migration

Post by lettie_dude »

Hi

Have found the possible reason for the session problems on the following link.

http://bugs.php.net/bug.php?id=20720&edit=2

So this problem is kind of resolved!

Will avoid using empty code in future.

Thanks to all for responses.
Post Reply