我习惯于使用PHP和JavaScript,但我现在已经开始在Coldfusion中开发一个项目。Coldfusion字符串== true或空==错误?
在PHP中,我习惯于字符串是“truthy”,空/ null是“falsy”。
这似乎并不适用于ColdFusion(特别是v8)。
我想作以下工作,但无法弄清楚如何使CF看到的truthy字符串:
<cfset x = "path\to\something.cfm">
<cfif x>
x is truthy
<else>
x is falsy
</cfif>
我总是得到错误:cannot convert the value "path\to\something.cfm" to a boolean
isBoolean()
排序作品,但感觉不够健壮。- 似乎有不为'isString() - 但是这将是问题,因为上面反正
YesNoFormat()
奇怪给我同样的错误(什么我会虽然它应该做的完全相反)
最好的选择是检查Len(X),它将返回0或1+,1+评估为true。 – Busches