Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Migrating PHP 4 hosting to PHP 5.2
PHP 4.x and PHP 5.2.x each have specific plus points and are only loosely compatible with one another; a fair percentage of scripts designed for PHP 4 do not work with PHP 5 and vice versa. We provide details below, but we strongly urge you, before requesting migration to the new platform, to fully test your site on your own machine (the Apache web server can be downloaded free of charge at http://www.apache.org; PHP versions 4 and 5 are available for it from http://www.php.org).
If you use PHP scripts that are not designed for Version 5, you will definitely need to check whether their authors offer updates or new versions that work on Version 5.
What if you wrote the PHP code for your site a few years ago and are not sure whether it works with PHP 5? Here are a few differences between the two versions:
strrpos and stripos() now work on a whole string. Originally, these functions searched for the occurrence of a single character in a string.
Using an invalid index on a character string produces an E_ERROR rather than an E_WARNING (e.g.: $str = 'abc'; unset($str[0]);)
array_merge() will now only accept arrays. If you wish to add an element to an array and absolutely must use this function (rather than array_push), you will need to place the element in question into an array: array_merge($myarray, array ($myelement) ); If you continue to use this function with an element that is not an array, an E_WARNING is generated and the resulting array is empty.
The PATH_TRANSLATED server variable may no longer necessarily contain the same value as in PHP 4. Previously, this was sometimes used in the case of link rewriting in Apache (ModRewrite).
The T_ML_CONSTANT no longer exists (this was defined by the Tokenizer extension).
The CLI version in PHP 5 will always use the global variables $argc and $argv.
An object with no properties is no longer considered to be empty.
get_class() returns the name of the function as declared, without case modification. In PHP, the name returned was always lower case. The same goes for the predefined magic constants __CLASS__, __METHOD__ and __FUNCTION__.
ip2long() now returns the boolean value false if the address given is incorrect. In PHP 4, the function returned -1.
The is_a() function is deprecated and must no longer be used. You should use the instanceof operator instead.
May now longer reassign $this inside an objet.
include_once() and require_once() first canonicalise the path to be included in Windows, and hence including A.php and a.php will end up only including the file once.
The following are reserved keywords in PHP 5 and should not be used: exception, interface, protected, throw, abstract, implements, clone, final, public, try, this, php_user_filter, private, catch. Most of these keywords are the result of the extended concept of an object in PHP 5, along with the concepts of private/public variables, error handling (try/catch, which Java enthusiasts will be all too familiar with), etc.
Link to this FAQ: