问题描述
停止ColdFusion输出的空格的正确方法是什么?
What would be the correct way to stop the white space that ColdFusion outputs?
我知道有 cfcontent
和 cfsetting enableCFoutputOnly
。
推荐答案
除了< cfsilent>
,< cfsetting enablecfoutputonly =yes>
和&cf; cfupcessingdirective suppressWhiteSpace =true>
为< cfcontent reset =true/>
。您可以使用文档开头删除空格。
In addition to <cfsilent>
, <cfsetting enablecfoutputonly="yes">
and <cfprocessingdirective suppressWhiteSpace = "true">
is <cfcontent reset="true" />
. You can delete whitespaces at the beginning of your document with it.
HTML5文档将以如下方式开始:
HTML5 document would then start like this:
<cfcontent type="text/html; charset=utf-8" reset="true" /><!doctype html>
XML文档:
<cfcontent reset="yes" type="text/xml; charset=utf-8" /><CFOUTPUT>#VariableHoldingXmlDocAsString#</CFOUTPUT>
这样你就不会得到Content is not allowed in prolog - XML文档的错误。
This way you won't get the "Content is not allowed in prolog"-error for XML docs.
如果你从一个函数中得到不需要的空格,使用输出
-attribute来抑制任何输出, result as string - 例如:
If you are getting unwanted whitespaces from a function use the output
-attribute to suppress any output and return your result as string - for example:
<cffunction name="getMyName" access="public" returntype="string" output="no">
<cfreturn "Seybsen" />
</cffunction>
这篇关于白色空间/冷灌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!