How to call a php function within <script> tag from coldfusion 9

孤街醉人 提交于 2019-12-23 13:01:35

问题


I have this nice big Dev Kit written in PHP, but the application I'm currently developing is in CFML.

In an attempt to avoid rewriting the PHP, I'm going to try to just wrap the PHP in CF <script> tags and call the PHP functions when I need them.

Does anyone have any idea how to call one of those PHP functions inline in CF?


回答1:


There's no built-in way to do this, but using CFGroovy (which allows you to inline any Java Scripting API-compliant language implementation) and Quercus (a PHP implementation in Java), you may be able to pull off what you want/

CFGroovy: http://www.barneyb.com/barneyblog/projects/cfgroovy2/

Quercus: http://www.caucho.com/resin-3.0/quercus/

A simple example including source code: http://www.barneyb.com/cfgroovy2/




回答2:


You can't. It's a whole other app engine. You could use CFHTTP to call a PHP page - but it's a bit overkill. You can look at Sean's solution here:

http://corfield.org/entry/ColdFusion_8_running_PHP




回答3:


Edward M. Smith is right. You may be able to mix PHP and CFML by using Resin as your JVM. While I have not done so, I do believe it is possible to have Resin interpret your PHP code from within the same context as a CFML (ColdFusion) Web site.

A .cfm/.cfc could not contain any PHP and a .php file could not contain any CFML/CFScript; however, those files could live side by side within your www.something.com domain.

Resin http://www.caucho.com/ is a Web Server/PHP Interpreter that is very fast and written in Java. It is the bundled JVM for the open source CFML project Railo.

Hope this helps.




回答4:


You can pass data back and forth by having php/coldfusion store/retrieve client array's or variables.

One other choice is to force coldfusion to parse through .php files, for any coldfusion inside there. How it would handle the mixture of coldfusion and php, I am not sure...



来源:https://stackoverflow.com/questions/3085765/how-to-call-a-php-function-within-script-tag-from-coldfusion-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!