我在 Coldfusion 2018 中使用会话变量,我试图弄清楚如何通过设置 if 语句的方式添加变量。
<cfif isDefined("session")
and structKeyExists(session, 'checkout')
and structKeyExists(session.checkout, 'info')
and structKeyExists(session.checkout.info, 'andor_1') >
<cfif session.checkout.info.andor_1 eq "And">
<strong>- All signatures are required.</strong>
</cfif>
</cfif>
or
<cfif isDefined("session")
and structKeyExists(session, 'checkout')
and structKeyExists(session.checkout, 'info')
and structKeyExists(session.checkout.info, 'bandor_1') >
<cfif session.checkout.info.bandor_1 eq "And">
<strong>- All signatures are required.</strong>
</cfif>
</cfif>
if 语句几乎相同,andor_1
或者bandor_1
可能并不总是存在,这就是我使用 isDefined 的原因。
我试过使用||
and or
。
<cfif isDefined("session")
and structKeyExists(session, 'checkout')
and structKeyExists(session.checkout, 'info')
and structKeyExists(session.checkout.info, 'andor_1')
|| isDefined("session")
and structKeyExists(session, 'checkout')
and structKeyExists(session.checkout, 'info')
and structKeyExists(session.checkout.info, 'bandor_1')>
<cfif session.checkout.info.andor_1 eq "And" || session.checkout.info.bandor_1 eq "And">
<strong>- All signatures are required.</strong>
</cfif>
</cfif>
任何结合这些的帮助将cfifs
不胜感激。