简体   繁体   English

ColdFusion中是否有将未定义值转换为空字符串的快捷方式?

[英]Is there a shortcut in ColdFusion for converting undefined value to empty string?

I find myself writing code like this in ColdFusion a lot: 我发现自己经常在ColdFusion中编写这样的代码:

<cfset inputval = "" />
<cfif IsDefined("Form.Releases")>
    <cfset inputval = Form.Releases />
</cfif>

This is very cumbersome. 这很麻烦。 I just want an undefined value to be converted to an empty string. 我只希望将未定义的值转换为空字符串。 Is there any kind of shortcut? 有没有捷径可走?

For example, in PHP I do this with strval function, ie: 例如,在PHP中,我使用strval函数执行此操作,即:

$inputval = strval($_POST['Releases']);

Check out cfparam 签出cfparam

http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b13.htm http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b13.htm

<cfparam name="Form.Releases" default="">
<cfset inputval = Form.Releases />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM