gpt4 book ai didi

使用 IsDefined() : parameter must be a syntactically valid variable name 的 ColdFusion 错误

转载 作者:行者123 更新时间:2023-12-04 01:49:22 27 4
gpt4 key购买 nike

在 ColdFusion 中,当我调用 IsDefined("root.L1[1].L2") 时,出现以下错误:

Parameter 1 of function IsDefined, which is now root.L1[1].L2, must be a syntactically valid variable name.



这是一个有效的变量名,那么是什么给出的呢?

这是我的简化测试代码:
<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>

最佳答案

尝试

StructKeyExists(root.L1[1],"L2")

而不是 isDefined()

我依稀记得 isdefined() 的复杂变量存在问题,但我不记得版本了。

关于使用 IsDefined() : parameter must be a syntactically valid variable name 的 ColdFusion 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3400795/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com