1

Most results I get on google is how to get both versions running simultaneously on the same server but at different URLS but that's not what I want.

I'd like, for example, to get http://localhost to run PHP4 and PHP5 at the same time on the same site. This is because I have a website that has old code from PHP4 that breaks up when executed in PHP5.

The same site also has some components written only in PHP5, so I would like to run both PHP versions at the same time in the same site.

I'm on Windows XP running Apache, I wouldn't mind switching to IIS7 if it's required.

I'm already aware of the security risks associated with this potential solution.

1
  • 1
    Not only is this a confusing question, but even assuming what you're asking is possible, it can't be any easier than upgrading your old code. So try that instead. Commented Nov 15, 2011 at 16:10

1 Answer 1

1

You cannot have one PHP script executed by both the PHP4 runtime and the PHP5 runtime at the same time. There's only one interpreter running at any time. So, no execution of "these few lines and PHP4" and the "other ones over there in PHP5" and jumping back and forth between the two.

It's however possible to connect two separate scripts. Create the normal PHP output script and invoke any PHP4 code like this:

<?php // do some PHP5 code here code_here(...); // then invoke the script parts for PHP4 passthru("php4-cgi.exe .../script2.php4"); # MAYBE REQUIRES setenv("SCRIPT_FILENAME", ...); ETC. ON WINDOWS // then do some more PHP5 thingys ... ?> 

The PHP4 interpreter will inherit the CGI environment, thus allowing to run as if it was the main script itself. With some cleaning up of that environment (regex filter ALL the variables) it doesn't have to be much of a security concern either. (But you didn't bother to update the code in the first place, so.)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.