ColdFusion 9 和 ColdFusion 7 之间关于 CFScript 的向后兼容性?
我是一个完整的 ColdFusion 新手,所以为我即将到来的无知提前道歉。
我们的现有 CFScript 存在问题。有问题的脚本包含以下行:
...
if (fields.length() != 0) {
// do something
}
...
该脚本在 ColdFusion 9 中运行成功,但在尝试在 ColdFusion 7 中运行该脚本时我们看到以下消息:
...
Invalid token '!' found on line...
...
我猜 ColdFusion 7 不喜欢 '!=' 运算符,我我说得对吗?
如果是这样,CFScript 是否还有其他向后兼容性问题可能导致我们出错?我一直在寻找资源,但似乎没有任何明确的信息。
谢谢。
I am a complete ColdFusion newbie so apologies in advance for my upcoming ignorance.
We are having an issue with an existing CFScript. The problematic script contains the following line:
...
if (fields.length() != 0) {
// do something
}
...
The script runs successfully in ColdFusion 9, but we see the following message when trying to run the script in ColdFusion 7:
...
Invalid token '!' found on line...
...
I'm guessing that ColdFusion 7 does not like the '!=' operator, am I correct?
If so, are there any other backward compatibility issues with CFScript that could cause us to trip up? I've been searching for resources but there doesn't seem to be anything definitive.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,在 CF7 中,您需要使用 ColdFusion 的本机比较运算符,在您的情况下为
neq
。将
==
替换eq
!=
替换为neq
>
替换为gt
<
与lt
>=
与gte
<= 与
lte
%
与mod
就可以开始了。这些算子是向上兼容的,CF9会理解它们。
除此之外,
var
声明的变量)分组到 ColdFusion 7 中函数的顶部。此限制在后续版本中已消失ColdFusion,但以这种方式编写的脚本当然会继续运行。local
范围。此作用域在 CF7 和 CF8 中不可用,但按照惯例,人们在 CF7 函数顶部添加了var local = StructNew();
,这也适用于 CF > 。 7.Yes, in CF7 you need to use ColdFusion's native comparison operators, in your case
neq
.Replace
==
witheq
!=
withneq
>
withgt
<
withlt
>=
withgte
<=
withlte
%
withmod
and you're good to go. These operators are upward-compatible, CF9 will understand them.
Other than that,
var
) at the top of a function in ColdFusion 7. This restriction has gone away in later editions of ColdFusion, but scripts written that way will of course continue to run.local
scope as of CF9. This scope was not available in CF7 and CF8, but by convention people added avar local = StructNew();
at the top of their CF7 functions, which will also work in CF > 7.你是对的 - 类似 Javascript 的运算符(!=、==、|| 等)仅在 ColdFusion 9 中引入,同时还提供了更多的脚本支持。
这主要与 CFC 的完整脚本支持有关,但可能还有很多其他问题......
You're right - the Javascript-like operators (!=, ==, ||, etc.) were only introduced in ColdFusion 9, along with a whole lot more scripting support.
This mostly relates to full script support for CFCs, but there are probably plenty of other other gotchas out there...