Coldfusion 8:IsDefined(“URL.variable”) 并且不是“”?
我试图找出 url 变量是否存在,如果不存在,请确保它不为空。
这不起作用:
<cfif IsDefined('URL.affiliateId') and is not "">
//
</cfif>
I'm trying to find out if a url variable exists, and if it doesn't, make sure that it's not empty.
This does not work:
<cfif IsDefined('URL.affiliateId') and is not "">
//
</cfif>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您还可以使用来简化逻辑。以确保 URL 变量始终存在。那么您不需要 2 个条件,而只需要 1 个。
You can simplify the logic a bit as well by using <cfparam> to ensure that the URL variable always exists. Then rather than having 2 conditions, you just need 1.
忽略大部分空白
...或者交替
To ignore most white space
... or alternately
我将总结答案并提供我的版本:
您不需要 structKeyExists 或 isDefined,最好避免它们。此外,您不需要“len()”之后的“大于零”部分。
I will just sum up the answers and offer my version of it:
You do not need structKeyExists or isDefined and it would be better to avoid them. Also you do not need the 'greater than zero' part after the 'len()'.