Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysterious space at beginning when string returned from a function

Why is there a space at the beginning of the string returned from a function?
The solutions seems easy but I am unable to find the reason.

Code

<cffunction name="getString" returntype="string">
    <cfreturn "hello">
</cffunction>
<cfoutput>  
[#getString()#] = getString()
</cfoutput>

Output

[ hello] = getString()
like image 891
Saurabh Sharma Avatar asked Dec 11 '12 03:12

Saurabh Sharma


1 Answers

By default CFML functions will produce output, including whitespace. This can cause unwanted white space. Add output="false" to your function.

<cffunction name="encodeMyPath" returntype="string" output="false">
like image 91
Jason Dean Avatar answered Nov 15 '22 08:11

Jason Dean