views:

612

answers:

5

I am trying to make this feature available, maybe in an apache .htaccess file.

A: 

My understanding is that everything in PHP 4 is in PHP 5, so if you install PHP 5 and configure it, you will be able to use all features in both 4 and 5.

Thomas Owens
Thomas - you won't believe the stuff the PHP crowd break between major releases. Our unix guys are about to deploy PHP5 for new sites on the shared environment and keep PHP4 for existing sites, just in case. When they did PHP3 -> PHP4 it was a bit of a 'mare.
Kev
There were a few things that changed that could break some apps, but generally the move from 4->5 is not nearly as bad as 3->4 was.
acrosman
Still....offering both versions mitigates the risk of breaking existing sites, especially when you're running a thousand sites per box and you have a good few boxes.
Kev
A: 

Just use the CGI binarys. Or recompile PHP5 with X feature.

DylanJ
A: 

My web host (1&1) does this; to use php5 I have to use .php5 extensions or add an .htaccess command to use php5 for my .php files.

I would think it's simply a matter of installing php4 and php5 to separate directories and telling apache to interpret .php files with php4 and .php5 files with php5.

Xnapid
I would reverse this to use .php for PHP5 and .php4 for PHP4. Use the odd extension for the out of date version.
acrosman
A: 

If you are using a control panel application on your server such as cPanel, this can probably already handle this for you.

If you are on a bare server, simply have PHP 5 run using one method (e.g. DSO) and have PHP 4 run using a different method (e.g. SuPHP). You can then use a .htaccess file to determine which version of PHP to use or just have .php for PHP 5 and .php4 for PHP 4 files.

However, there is a huge overlap between PHP 4 and PHP 5. The only major difference I can think of offhand that one would likely encounter is XML processing.

coderGeek
+1  A: 

I used the virtual server config to setup several folders with PHP5 and some with PHP4 on my PC to test code. I also set them up with different hostnames (also in the windows host file). (I dont have access to that machine anymore, but here is what I remember.)

Just include one of the following (for linux)

AddHandler php4 .php
Action php4 /cgi-bin/php4

or

AddHandler php5 .php
Action php5 /cgi-bin/php5

in the virtual server config.

If you want to use them for the same (virtual) server, one of the file extensions would have to be renamed to .php5, .php4 or similar.

OIS