PHP code revisions needed when porting code to new server

Discussion about BCA's Internet Hosting Service
User avatar
David Gibson
Posts: 526
Joined: Thu 16 Mar 2006 23:45

PHP code revisions needed when porting code to new server

Post by David Gibson » Wed 25 Feb 2009 17:08

I might be the only person this affects, but I thought it useful to document my problems - if only so I can refer back to it myself.

Im in the process of testing the BCRA pages on the new server, and they have thrown up some obscure problems caused by the fact that the new server runs PHP5 and not PHP4.

1) In my code I define a function called hash() but it turns out that this is a built-in function in PHP5 and the compiler throws up an error "you cannot redfine this function". What other new functions might screw up existing code?

2) I use a key value abstract in an array, i.e. $bibliography[abstract] and it turns out that abstract is a reserved word in PHP5. What other new reserved words might screw up existing code?

Of course, this is sloppy coding on my part, I should have used $bibliography['abstract'] but that throws up another problem in that, with the single quotes present there, you need to put curly brackets in statements like echo "This is the {$bibliography['abstract']} entry";. Again, arguably sloppy coding on my part to omit the {} in the first place but <shrug> I only do this in my spare time :-)

Hopefully I wont find any other problems in porting the site across

There's a wider point here: if ever you upgrade any modules on the site, Cookie/Les, that might affect users, can you let us know?