coldfusion - 如何知道coldfusion中变量的范围?

标签 coldfusion coldfusion-10

在 Coldfusion 中,我想知道特定变量的范围,我怎样才能得到它?

实际上,在现有的 cfm 文件中使用了一个未在该页面中声明的变量。但由于它没有抛出任何错误,这就是为什么我认为该变量可能在其他范围内声明。

那么我可以知道它是在哪个范围内声明的吗?

最佳答案

无法检查它所在的范围 - 您只能检查所有范围:

StructKeyExists(variables, "myVar");
StructKeyExists(session, "myVar");
StructKeyExists(form, "myVar");
StructKeyExists(request, "myVar");
StructKeyExists(url, "myVar");

等等

此处范围的优先级 http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec09af4-7fdf.html

有关该主题的更多信息,请参见此处 What is the scope evaluation order in ColdFusion when setting a variable?

关于coldfusion - 如何知道coldfusion中变量的范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20420485/

相关文章:

mysql - 使用 mySQL 数据库在 CFC 中进行麻烦的 coldfusion 联合查询

javascript - JQuery 多月日历 View

mysql - 分页 - 如果满足特定条件如何跳过记录

rest - 在 ColdFusion10 中禁用/休息 URL

Coldfusion 10 日期格式问题

正则表达式前缀环视在coldfusion 10中不起作用

c# - Coldfusion - 如何实时更新表格单元格?

coldfusion - 使用 cfscript 创建的查询的 cfoutput

Coldfusion中的.Net时间字符串转换