Skip to main content
Inspiring
July 5, 2021
Answered

cffunction possible error in output?

  • July 5, 2021
  • 1 reply
  • 196 views

Consider this function which returns whatever its input is::

<cffunction name="FredTest" output="yes" access="public" returnType="string">
<cfargument name="lsVarIn" type="string" required="true"/>
<cfreturn lsVarIn />
</cffunction>

I test the function using: ABC#FredTest("DEF")#GHI

I expected to see the output as ABCDEFGHI but instead got ABC DEFGHI.  I can't figure out why.  Everytime I try to use cffunction to return a string CF adds a space in front of the output.  Any idea why?  Thanks.

    This topic has been closed for replies.
    Correct answer BKBK

    It is not an error. The extra space is just the empty space from the body of the function. 

     

    Solution:

    Set output to "no" in the function definition. That is, output="no".

    That is the recommended setting, unless in cases where you have good reason to set it to "yes". 

    1 reply

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    July 6, 2021

    It is not an error. The extra space is just the empty space from the body of the function. 

     

    Solution:

    Set output to "no" in the function definition. That is, output="no".

    That is the recommended setting, unless in cases where you have good reason to set it to "yes". 

    Inspiring
    July 6, 2021

    BKBK, Thank you so much.  You saved me a lot of work trying to find a work around.  Thanks again!