English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

So here's an interesting one. I have no idea if this is possible, but hopefully someone here knows of a way. I have a site I wrote in coldfusion. It's written in this god-awful language because we have to run a proprietary third party client to manage member data. So programming the site in anything but coldfusion was unfortunately not an option. The page is built dynamically, with the menu, header, footer, and all content being included from the index file based on URL variables.

There are, of course, plenty of things PHP can do that coldfusion can't and I'd like to do some of these things on this site. So what I'm wondering is... is there any way I can get the PHP engine on the server to somehow compile .php files containing php code or preprocess them BEFORE my coldfusion engine includes the php file?

Thanks for any help anyone can offer.

2007-02-27 07:59:37 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

To be perfectly clear, I'm not looking to change the site or reprogram anything that's currently there. I just want to be able to include PHP code from a coldfusion file and have that PHP code somehow already processed by the time it hits the coldfusion.

2007-02-27 08:11:04 · update #1

I have tried simply including a file containing PHP and the code comes out completely unparsed.

2007-02-27 08:34:36 · update #2

4 answers

Is your .php file just generating output, or is it doing some kind of calculation(s) that your CF code will depend on? If it's the former, you should be able to use the tag to generate your output.

To do this, make sure your .php file sits somewhere within your CF application. Then, your code will look similar to this:






#cfhttp.FileContent#

2007-02-27 13:10:59 · answer #1 · answered by Defenseman Emeritus 3 · 0 0

So essentially, you have a dynamically generated page, and you want to run PHP and then ColdFusion interpreters, in order. A key parameter here is that the PHP script needs to finish executing before you start the ColdFusion one; they can't run simultaneously. If you can do this at all -- and I'm not at all sure that you can, because I'm not really a Coldfusion expert -- you would do it in this fasion:

1. Rename all of your dynamically-generated pages to conform to the expression *.php. This should prevent the ColdFusion scripting engine from reading them, provided the settings are correct.

2. Write your PHP code in such a manner that it generates a string containing xhtml + Coldfusion markup with the appropriate script tags. Every dynamically-generated page needs to do this. Importantly, it needs to do it before any data is passed back to the client via HTTP.

3. Write a generic PHP script with a function that the giant Step 2 string will be passed to. This script will write the string to a file (with an arbitrary and unique name -- you can recycle file names every 1000 or so to save space). This file will have a .cfm extension. When the script finishes, it will return the file name that it's decided to use to the script that called it.

4. The script that called it -- the one you built in step 2 -- will redirect to the new ColdFusion page using an HTTP header redirect. (I forgot to mention in step 2 that you would have to do this).

This would accomplish your stated goals, but there are HUGE downsides in terms of processing cost. If you can do at least most of what you need to do with ColdFusion, then stick with it; this kind of multi-language scripting setup is kludgy in the extreme. ColdFusion is slow and unwieldy to start with, and this would just make it much moreso.

EDIT:
Another method that *might* work -- there could be simultenaity issues, depending on what you're doing -- is adding the coldfusion file extension to the list that the PHP interpreter processes. This is about a 30-second fix on Apache. Just look for a list that says "*.php" and add whatever other kinds of pages you want processed to it.

2007-02-27 08:43:19 · answer #2 · answered by Drew 6 · 0 0

If you've got PHP running on the server, I believe that any file you do include that is php will be parsed before being brought in.

2007-02-27 08:26:25 · answer #3 · answered by Clinton G 2 · 0 0

The best thing to do would be to build a Test Server so that you have no impact on your main servers' performance and no possible impact on its software at all.

You would have a separate server that SHOULD be the same as what you are running your current website off of just to mitigate any other factors that could skew your results.

2007-02-27 08:04:05 · answer #4 · answered by phoenix_61_98 3 · 0 0

fedest.com, questions and answers