在ColdFusion中,当我打电话时IsDefined("root.L1[1].L2"),我收到以下错误:
函数IsDefined的参数1,现在是root.L1 [1] .L2,必须是语法上有效的变量名.
这是一个有效的变量名,所以给出了什么?
这是我简化的测试代码:
<cfscript>
root = StructNew();
root.L1 = ArrayNew(1);
root.L1[1] = StructNew();
root.L1[1].L2 = "foo";
WriteOutput("root.L1[1].L2 is: #root.L1[1].L2#<br/>"); //no exception
if(IsDefined("root.L1[1].L2")) //exception!
WriteOutput("It is defined!");
else
WriteOutput("It is not defined!");
</cfscript>
Run Code Online (Sandbox Code Playgroud)
Ste*_*tti 13
尝试
StructKeyExists(root.L1[1],"L2")
Run Code Online (Sandbox Code Playgroud)
而不是isDefined()
我模糊地回忆起使用isdefined()存在复杂变量的问题,但我不记得版本了.
| 归档时间: |
|
| 查看次数: |
6300 次 |
| 最近记录: |