PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Miscellaneous Questions> <PHP and other languages
Last updated: Fri, 02 May 2008

view this page in

Migrating from PHP 4 to PHP 5

This faq section will help you migrate from PHP 4 to PHP 5.

  1. Migrating from PHP 4 to PHP 5
  2. Does MySQL work in PHP 5? It seemed to have disappeared.
  3. I hear PHP 5 has an entirely new OOP model, will my existing OOP code work? Where do I find information on these new OOP features?
  4. So besides the new OOP model, what else has changed in PHP 5? Also, is there a PHP 5 specific version of the PHP manual?

Migrating from PHP 4 to PHP 5

Although PHP 5 offers many new features, it's designed to be as compatible with earlier versions of PHP as possible with little functionality being broken in the process.

Be sure to read the appropriate PHP 5 migration appendix of this manual as it contains even more information on the topic of migrating to PHP 5.

Does MySQL work in PHP 5? It seemed to have disappeared.

MySQL is supported with the only change being that MySQL support is no longer enabled by default in PHP 5. This essentially means that PHP doesn't include the --with-mysql option in the configure line so that you must now manually do this when compiling PHP. Windows users will edit php.ini and enable the php_mysql.dll DLL as in PHP 4 no such DLL existed, it was simply built into your Windows PHP binaries.

Also, the MySQL client libraries are no longer bundled with PHP. More details on this topic are covered in the following FAQ and be sure to read the MySQL section for details on installing MySQL. An example configure line would be --with-mysql=/usr while Windows users will need the libmySQL.dll available to the system.

I hear PHP 5 has an entirely new OOP model, will my existing OOP code work? Where do I find information on these new OOP features?

The main change in PHP 5 is to the OOP model as PHP 5 now uses the Zend Engine 2.0. The zend.ze1_compatibility_mode directive enables compatability with the Zend Engine 1.0 (PHP 4).

The new OOP model is documented in the OOP language reference and OOP migration appendix sections.

So besides the new OOP model, what else has changed in PHP 5? Also, is there a PHP 5 specific version of the PHP manual?

Few other changes exist, see the migration 5 appendix for details. There won't be a PHP 5 specific version of the manual as the bulk of PHP remains the same.



Miscellaneous Questions> <PHP and other languages
Last updated: Fri, 02 May 2008
 
add a note add a note User Contributed Notes
Migrating from PHP 4 to PHP 5
benjaminlindelof at yahoo dot com
13-Sep-2007 07:41
Everytime I post something here, it is deleted by a moderator.

PHP elitism?  Don't want to share tips for migrating to PHP5?

Suggesting we switch to .NET to avoid your issues?  Yes!
xieoy at hotmail dot com
28-Aug-2007 10:09
I am using PHP5.2.2 for winXP.
today, I downloaded php-4.4.7-Win32 here, and clicked php.exe and go-pear.bat.
I didnt understand what happened, then I just closed two 
windows.
But, to my surprise, my web which worked succesful on my computer doesn't work now, it disabled to connect mysql!!!!

Then I uninstalled PHP5.2.2,and installed again, but it doesnt work either!!!!!!!!!!!!!!!!!!!!!!!!!!!

why????????????

(windowsXP+PHP5.2.2+Mysql5+Apache2.2.4)
gfrank at neoservers dot com
24-Jun-2007 08:17
To get PHP5 and PHP4 to work at the same time you will also need to change all "php_value", "php_flag", "php_admin_flag", and "php_admin_value" occurences; otherwise, you can't set configuration file settings.
odnowa-sql at o2 dot no-spam pl
29-Apr-2007 05:13
You can run PHP4 and PHP5 as Apache2 modules at the same time. The trick is to hack the sources a little bit.
Change all occurences of application/x-httpd-php (and MIME type for sources) to application/x-httpd-php5 and then add that mime type to apache conf.

Miscellaneous Questions> <PHP and other languages
Last updated: Fri, 02 May 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites