CFEXIT在CFC中的功能中做了什么?

时间:2011-07-27 18:36:42

标签: coldfusion

<cfexit>在函数内部做什么,在cfc中?

是否与<cfabort>相同?

我正在重构一些遗留代码,并想知道我是否需要特别注意它......

感谢。

1 个答案:

答案 0 :(得分:8)

我对基本<cfexit>行为的回忆是:

  1. 在CFC中使用,cfexit退出cfc函数。但 继续处理呼叫页面。
  2. 如果在函数内,但不在cfc内,则处理中止。

  3. <强>更新 我刚刚确认CF9.0.1下的行为

    结果(使用cfexit)

    Start calling page 
    Called test()
    Finish calling page 
    Called on requestEnd
    

    结果(使用cfabort)

    Start calling page 
    Called test()
    Called on requestEnd
    

    <强> Test.cfm

    Start calling page <br />
    <cfset createObject("component", "Foo").test()>
    Finish calling page <br />
    

    <强> Foo.cfc

    <cfcomponent>
        <cffunction name="test" output="true">
            Called test()<br />
            <cfexit>
        </cffunction>
    </cfcomponent>