|
|
| How to Convert PHP4 Applications to PHP5 |
There are many people fond of computers who want
to convert PHP 4 applications to PHP 5, but the sometimes regard
this step like a journey into an unknown world, therefore they need
guidance.
Their problems might be:
1. Most of the hosting providers don’t offer PHP 5 support.
Then what should you do? Should you look for another hosting or
should you write your code in order to support both versions?
2. Which are the major differences within the code? It is
usually known that mysql functions are used instead of mysql for
working with MySQL. What else should I know?
3. Is PHP 4 code compatible with PHP 5?
Firstly, you have to install PHP 5 and run the code written by you
in PHP 4 and you’ll see if it is working or not.
Secondly you have to know that there are providers who do offer PHP
5 for some time. Therefore you must find a proper hosting.
Furthermore, you can use mysql functions for PHP 5 too. But there
are some major changes in working with objects, but if you have got
a procedural code, there won’t be any problem as long as you don’t
have class functions with reserved names which appeared in PHP 5.
(Exception, interface, try, abstract, catch, public, protected,
private).
According to statistics, less than 1% of the PHP 4 users have never
used one of the previous words for the name of a function or class.
The support for xml has changed and here you can have some problems.
The extension called dom_xml does not belong any more to PHP 5.
There is used a new extension DOM or Simple XML.
Finally, if you add E_STRICT at the errors reporting level, you can
correct other problems too, which are considered now deprecated
(using var instead of public/protected/private, references etc). |
|