douye9822 2016-06-28 21:11
浏览 24

Coldfusion和php,在同一个文件中?

On this server, I can use both .cfm and .php files. Both types will be parsed, as expected.

However, I want .cfm files to be parsed for php, as well. For example,

//test.cfm:
<cfoutput>hello from cf</cfoutput>    
<?php echo 'hello from php'; ?>
// outputs the php, verbatim, without processing :(

I know that I can change the php config, to parse .cfm. I dont know what order the parsing will take place or any other pros and cons, tricks and tips.

The goal here is that I want to wrap php (which i know well) into a cfm file (much less experience). The cfm file will be in an admin section, which automatically checks the user auth, and includes other cf files.

So, it seems to me that if coldfusion parses the file (checking the user-auth and all that), then hands it over to php, that would be the process that I am looking for.

  • 写回答

2条回答 默认 最新

  • dongmei1828 2016-06-29 14:11
    关注

    This has been done:

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

    Most of the documentation has mixing ColdFusion and Groovy, but other languages can be mixed in too.

    Example code:

    <cfimport prefix="g" taglib="engine" />
    
    ...
    
    <h2>Run some PHP (via Quercus)</h2>
    <cftry>
       <g:script lang="php">
          <?php
          $variables["myArray"][] = "Pretty Happy People wrote PHP.";
          echo "<pre>";
          var_dump($variables["myArray"]);
          echo "</pre>";
          ?>
       </g:script>
       <cfcatch type="CFGroovy.UnknownLanguageException">
         <p>Quercus needs to be added to your classpath for the PHP example to work</p>
       </cfcatch>
       <cfcatch type="any">
         <p>Error running PHP code: #cfcatch.message#</p>
         <p>#cfcatch.detail#</p>
      </cfcatch>
    </cftry>
    

    Source: https://ssl.barneyb.com/svn/barneyb/cfgroovy2/trunk/demo/index.cfm

    评论

报告相同问题?

悬赏问题

  • ¥15 怎么获取下面的: glove_word2id.json和 glove_numpy.npy 这两个文件
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug