PHP 4 and PHP 5 together ?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

PHP 4 and PHP 5 together ?

Post by anjanesh »

Im using PHP 4.3.10 because my host uses it.
1. But now I want to try out PHP 5.0.3 without removing PHP 4.3.10. Is that possible ?
2. Is it possible to configure in Apache to handle both PHP 4.x and PHP 5.x types ? Say PHP 4.x files are having .php extension and PHP 5.x files have .php5 extension ?
C:\PHP => PHP 4.3.10 package
C:\PHP5 => PHP 5.0.3 package
3. If IT IS then how'll I get to have 2 php.ini files in C:\Windows - one for each ?
4. If all the above as possible then is it possible to club a PHP 4 code and a PHP 5 code in a single script like:

Code: Select all

<?php
// PHP 4 code
?>
<hr>
<?php5
// PHP 5 Code
?>
Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. yes
  2. yes
  3. you place them in differing locations and tell php where to look I believe
  4. not directly possible
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

yes, it's possible to have such setup (except mixing two flawors of php in the same file). Last time I tried to acomplish this I had to set both interpreters as a CGI (because I used PHPRC env. variable to control the location of php.ini) and then it worked flawlessly.

something like this:

Code: Select all

#excerpt from httpd.conf
    
    # PHP Handling

    # PHP 4
    AddType application/x-httpd-php .php
    ScriptAlias /php4/ "e:/php4/"
    SetEnvIf Request_URI "\.php$" PHPRC=e:/php4/php.ini
    Action application/x-httpd-php "/php4/php.exe"

    # PHP 5
    AddType application/x-httpd-php5 .php5
    ScriptAlias /php5/ "e:/php5/"
    SetEnvIf Request_URI "\.php5$" PHPRC=e:/php5/php.ini
    Action application/x-httpd-php5 "/php5/php-cgi.exe"
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Wow. I defintely got to try this (hopefully no crash). If it can work as cgi then it defintely should work as a module. Let me try with as module and post the result here.
Thanks
Post Reply